Configuration bits (also known as fuses) can be configured using one
of two methods:
- using #pragma config (see section 4.7.6), which
is a preferred method for the new code. Example:
-
- #pragma config CP0=OFF,OSCS=ON,OSC=LP,BOR=ON,BORV=25,WDT=ON,WDTPS=128,CCP2MUX=ON
#pragma config STVR=ON
- using `__code' and `__at' modifiers. This method
is deprecated. Possible options should be ANDed and can be found in
your processor header file. Example for PIC18F2550:
-
- #include <pic18fregs.h> //Contains config addresses and options
static __code char __at(__CONFIG1L) configword1l =
_USBPLL_CLOCK_SRC_FROM_96MHZ_PLL_2_1L &
_PLLDIV_NO_DIVIDE__4MHZ_INPUT__1L & [...];
static __code char __at(__CONFIG1H) configword1h = [...];
static __code char __at(__CONFIG2L) configword2l = [...];
//More configuration words
Mixing both methods is not allowed and throws an error message ”mixing
__CONFIG and CONFIG directives”.