Generating Configuration Bits in C Code
Microchip's MPLAB XC8 C compiler accepts #pragma directives to set the configuration bits.
The syntax for generating configuration bits:
#pragma config CONFIG_BIT_NAME = CONFIG_VALUE
Sample of Setting Configuration Bits in C

When setting configuration bits using C it is not necessary to know the word which contains the bit being set. All that is needed is the configuration bit name and the desired value.
The header files for each PIC16F1xx device contain the CONFIG_BIT_NAME and CONFIG_VALUE.
Once written the compiler directives must be added to the PIC MCU project in one of three ways:
- In a stand-alone C source file which is added to the project.
- In a header (.h) file placed in the project with an #include statement.
- Placed directly inside one of the source code files already in the project.
Generating Configuration Bits in Assembly
When working with assembly language, the programmer is required to generate the specific 14-bit values for each of the two configuration addresses. Once the patterns are generated the program makes a call to the CONFIG directive to set each of the configuration words.
A 14-bit pattern for each individual configuration bit setting is listed in the .INC file for each PIC MCU. The 14-bit value passed to the CONFIG directive is generated by logically AND-ing the bit settings in the .INC file.
The code to generate and load the configuration bits can be placed in any assembly source file in the project.