4.2 Specifying Configuration Fuses

While MPLAB XC8 will accept the code used with AVR-GCC to program the fuses in the Configuration Words, it also allows the Configuration Words to be specified in a simpler way. Consider the new constructs for new or migrated projects, but do not use a mix of programming methodologies.

MPLAB XC8 uses the config pragma to specify one or more Configuration Word setting-value pairs. The pragma ensures that the fuse data that is programmed into the device is placed in the correct section and linked at the correct address.

The general form of the pragma is:
#pragma config setting = value[,setting = value,...]
where setting is a fuse setting descriptor, e.g., WDTON, and value is a textual description of the desired state, for example CLEAR. Those states other than SET and CLEAR are prefixed with the setting descriptor, as in BODLEVEL_4V3 for the 4.3 Volt BODLEVEL setting, as shown in the following examples:
#pragma config SUT_CKSEL = SUT_CKSEL_14CK_62MS5
#pragma config BOOTRST = CLEAR, BOOTSZ = BOOTSZ_2048W_4800

For assistance with the setting-value names, open the avr_chipinfo.html file that is located in the compiler's docs directory. Click the link to your target device and the linked page will show you the pragma settings and values that are appropriate for your device, along with examples. Review your device data sheet for more information on the operation of the fuses.