27.4 Configuration Settings Using Macros

Note: Do not use this deprecated method for setting configuration bits with pragma statements used to set configuration bits (see Configuration Bit Access) in the same code.

Configuration Settings macros are provided that can be used to set Configuration bits. For example, to set the FOSC bit using a macro, the following line of code can be inserted before the beginning of your C source code:

_FOSC(CSW_FSCM_ON & EC_PLL16);

This would enable the external clock, with the PLL set to 16x, and enable clock switching and fail-safe clock monitoring.

Similarly, to set the FBORPOR bit:

_FBORPOR(PBOR_ON & BORV_27 & PWRT_ON_64 & MCLR_DIS);

This would enable Brown-out Reset at 2.7V, and initialize the Power-up timer to 64 ms, and configure the use of the MCLR pin for I/O.

Configuration Settings macros are defined in compiler header files for each device. Please refer to your device’s header files for a complete listing of related macros. Header files are located, by default, in:

<MPLAB XC16 Installation folder>/vx.xx/support/device/h

where vx.xx is the compiler version and device is your 16-bit device family.