25.4.14 Specifying Configuration Bits

The #pragma config directive can be used to program the Configuration bits for a device. The pragma has the form:

#pragma config setting = state|value

where setting is a configuration setting descriptor (for example, WDT), state is a descriptive value (for example, ON) and value is a numerical value.

Use the native keywords discussed in the Differences section to look up information on the semantics of this directive.

Example

The following shows Configuration bits being specified using this pragma.

#pragma config WDT=ON, WDTPS = 0x1A

Differences

The 8-bit compilers have used the __CONFIG() macro for some targets that did not already have support for the #pragma config.

The 16-bit compilers have used a number of macros to specify the configuration settings.

The 32-bit compilers supported the use of #pragma config.

Migration to the CCI

For the 8-bit compilers, change any occurrence of the __CONFIG() macro, for example,

__CONFIG(WDTEN & XT & DPROT)

to the #pragma config directive, for example,

#pragma config WDTE=ON, FOSC=XT, CPD=ON

No migration is required if the #pragma config was already used.

For the 16-bit compilers, change any occurrence of the _FOSC() or _FBORPOR() macros attribute, for example, from:

_FOSC(CSW_FSCM_ON & EC_PLL16);

to:

#pragma config FCKSMEM = CSW_ON_FSCM_ON, FPR = ECIO_PLL16

No migration is required for 32-bit code.

Caveats

None.