News:

Let's find out together what makes a PIC Tick!

Main Menu

Declare

Started by wessie, Nov 27, 2021, 08:39 PM

Previous topic - Next topic

wessie

Something that I always wondered about: If I use Declare within the program do I still need to set the registers as well?
i.e
Device = 12F683
Config FOSC_INTOSCIO, WDTE_OFF, PWRTE_OFF, MCLRE_OFF, CP_OFF, CPD_OFF, BOREN_OFF, IESO_OFF, FCMEN_OFF
Declare Xtal = 8        '8Mhz Crystal
Do I still need to do:
OSCCON = %01110000         '8Mhz selected

joesaliba

#1
Yes.

Declare Xtal is there to tell the compiler at which speed the PIC hardware is running.

OSCCON is actually setting the speed for the PIC.

In the manual, I think there is written that if xtal is not declared, then a default value of 4MHz is set.

Joe

wessie

Tx, appreciate the quick response.

Frizie

If XTAL is not declared, you will get an error message:
"No Xtal declare used in the program so the compiler does not know what frequency the device is running at"

The message seems clear to me  ;D
Ohm sweet Ohm | www.picbasic.nl