View and Set Configuration Bits
Configuration Bits

Configuration bits are a collection of specialized bits that can only be modified at program time. Configuration bits are "read" during reset and enable or disable hardware features in the microcontroller. The features controlled by the configuration bits include, but are not limited to, the clock source, Watchdog Timer, Brown-Out detect, and Memory Read protection. Configuration bits are not executable code. Essentially, they are fuses located in the program memory space.

How Configuration Bits are Set

Each PIC® MCU has its own set of configuration bits. The "Special Features" section of the individual datasheets contains the definition for each of the bits.

The setting for each configuration bit is determined by directives written in the application software. The syntax for the configuration bit settings is available from the compiler manual. This tutorial will show how to generate the proper configuration code without consulting the compiler manual for the proper syntax.

How to Display the Configuration Bits Window

From the main menu, select Window > PIC Memory Views > Configuration Bits.


The Configuration Bits window will open in a tab in the Output area under the editor.

Click image to enlarge.

How to Set Configuration Bits and Generate Initialization Code



In the Configuration Bits window, click on any value in the Options column and it will turn into a combo box that will allow you to select the value you desire.

The example on the left shows the Watchdog Timer is changed from enabled to disabled.



Click on the Generate Source Code to Output button.



The IDE will automatically generate the code necessary to initialize all the configuration bits to the settings you specified in the window. This code may now be copied and pasted into one of your source files, or you may save it to its own file and add it to your project. To save the file, right click anywhere in the Output window and select Save As from the popup menu as shown in the screenshot.



This code may optionally be inserted into the source file focused in the Editor. To insert the code, right click in the Configuration Bits window and select Insert Source Code in Editor from the popup menu as shown in the screenshot. The Toolbar button will also insert the code.

© 2020 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.