$CONFIG - Configuration bits

Language reference ›› Directives ››
Parent Previous Next

config-bits-directive = $CONFIG NONE | ( config-item { "," config-item } ) .
config-item = config-field-item | config-bit-item .
config-bit-item = config-item-name [ "=" ] config-bit-toggle .
config-bit-toggle = ON | OFF .
config-field-item = config-item-name [ "=" ] config-field-value .


NONE keyword – used alone – tells the compiler to not generate the CONFIG directive for the assembler. This is useful when using a bootloader that supersedes automatically all options.

The $CONFIG NONE directive may coexist with other $CONFIG directives, but simply they will not be generated.


This is the new syntax for configuration bits that matches the assembler config directive multi-byte complexity for the old alternate CONFIG syntax).
This directive is not allowed in units.
This directive may be used several times, but cannot be used after code generation has started.

<config-item-name> and <config-field-value>:

Legal configuration names as known by various MCHP documentation and MPLAB functionalities. The different possible names and values may be found in the Project Option's dialog.

<config-field-value> may start with a digit, which is not a legal Pascal identifier; in this case it should be quoted to be read as a string. Nevertheless, any identifier may be quoted.


For processors smaller than PIC18 with an unique configuration word, this directive may be replaced by a CONST definition that accepts configuration bits with an equivalent <config-item-name> equal to the left part of the name (with a leading underscore character) and <config-field-value> or <config-bit-toggle> equal to right part of the name (see example below). These special symbols are defined for the assembler.



{$CONFIG CPUDIV = OSC1_PLL2, FOSC = XT_XT, BORV = '1_9'}
{$CONFIG CPD=OFF, BOR=NSLEEP}

// This last one is equivalent to the old format:
CONST CONFIG = _CPD_OFF and _BOR_NSLEEP;


See also: Configuration bits declaration as CONST.