Configuration word register questions

Thread Starter

campeck

Joined Sep 5, 2009
194
Hey
The target device is a 12F683

#include <p12F683.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF)



I am going through some tutorials and this is at the top of the program.
What's going on here? Am I turning things off or on? Are these defaults?

Also to set the internal oscillator to 8Mhz bit 4,5 and 6 of the OSCCON register need to be set to 1.

so why does this tutorial tell me to use 0x70 which isn't that 112? Wouldn't I use 0x6F? and put that into OSCCON?

Thankyou.
 

Thread Starter

campeck

Joined Sep 5, 2009
194
Hmm. Is all I am doing is adding those presets to the config at the beginning of the program? So By adding the _WDT_OFF to the config I am just presetting the Watchdog to be off? What would happen If I left it out?
 

n9352527

Joined Oct 14, 2005
1,198
Notice that each config value are & (bitwise and-ed) together. So, a particular config value is defined as a mask with the corresponding bit set to zero. Leaving a config value will have no effect, if the default bit value of 1 is what you want (in other words, most of the configured peripherals will be on). Otherwise, the config value will have to be defined.
 

n9352527

Joined Oct 14, 2005
1,198
I don't think all the _XXX_ON labels are defined, but you better check on the datasheet first (or see in the include file). To set the peripherals to on, you leave out the particular config label. Notice that the /CPD, /CP and /PWRTE are inverted (on when the bit value is 0). The default settings then would be OFF, there must be a _XXX_ON labels to set those settings on, otherwise including either one of them (like _CP_OFF) would mean setting all three of them off (notice that they have the same hex value settings).
 
Last edited:

Tahmid

Joined Jul 2, 2008
343
Don't leave WDT on, it'll pose problems unless you really intend to use them (which I assume you don't since you're just starting new). So keep _WDT_OFF. For MCLRE, that's Master Clear Enable. If this is on, you need to pull the pin "Master Clear" which I think is pin 1, high. When this pin is low, the microcontroller is in reset mode, where it goes to reset vector. Keeping this pin low means no execution of code. If you keep MCLRE off, then you won't have this feature and you won't need the external resistor.
So it should be _WDT_OFF & _MCLRE_OFF (you could keep master clear on, but not WDT).

Hope this helps.
Tahmid.
 

Thread Starter

campeck

Joined Sep 5, 2009
194
I don't think all the _XXX_ON labels are defined, but you better check on the datasheet first (or see in the include file). To set the peripherals to on, you leave out the particular config label. Notice that the /CPD, /CP and /PWRTE are inverted (on when the bit value is 0). The default settings then would be OFF, there must be a _XXX_ON labels to set those settings on, otherwise including either one of them (like _CP_OFF) would mean setting all three of them off (notice that they have the same hex value settings).
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF)

So I could shorten that to...

__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _IESO_OFF & _FCMEN_OFF)

no _CP_OFF?

Tahmid, let me correct your statement, just for the sake of precision: If you don't use the pin as MCLR then the pin is an INPUT PIN by default and it is not wise to leave an input floating! So if the pin is not used and MCLR is off then the pin should be either pulled down or up.

Alberto
And they are high impedance when inputs right? So can I connect straight to Vss or Vdd?
 
Last edited:
Top