Configuration Bits in Mid-Range PIC Microcontrollers

Configuration Bits in Mid-Range PIC Microcontrollers

PIC16F877ADevice Configuration Bits allows the programmer to adjust certain condition that determines the operation modes of the microcontroller. That is the state of Configuration Bits determines the mode in which device operates when it is powered. These configuration bits are mapped in the program memory location 2007h. This location can’t be accessed during normal operation and can be accessed only at the time of programming. Their placement is automatically taken care by the device programmer or ICSP programmer. Hence selection of the correct microcontroller during programming is important.

MikroC users can edit these configuration bits by editing the project settings.

  • Project >> Edit Project
MikroC Project Settings
MikroC Project Settings

MPLAB, Hi-Tech C users can edit these configuration bits by using CONFIG Directive in the code or by using Configuration Bits tool.

  • Configure >> Configuration Bits
MPLAB - Configuration Bits
MPLAB – Configuration Bits

Don’t forget to uncheck “Configuration Bits Set in Code” in the Configuration Bits window if you are using Configuration Bits Tool.


Different Configurations

Oscillator Selection Bits

An oscillator is necessary to provide the required clock signals for the operation of the microcontroller. The oscillator may be in the following 8 different modes.

LP Low Frequency (Power) Crystal
XT Crystal/Resonator
HS High Speed Crystal/Resonator
RC External Resistor/Capacitor (Same as EXTRC with CLKOUT)
EXTRC External Resistor/Capacitor
EXTRC External Resistor/Capacitor with CLKOUT
INTRC Internal 4MHz Resistor/Capacitor
INTRC Internal 4MHz Resistor/Capacitor with CLKOUT

Read your Device datasheet for more details.

Watchdog Timer

You may have faced situations like your computer is hag or malfunctioning, in those cases we simply reset the computer by pressing reset button. This can also happen to a microcontroller and is not good to use a reset button to solve it every time. Watchdog timer is an electronic timer integrated in microcontrollers to detect and recover from above problems. It is actually a free run counter where our program needs to write zero in every time it executes correctly. If the program gets stuck, zero will not be written and the counter will reset the microcontroller upon achieving its maximum value.

Power-up Timer – PWRT

Power-up Timer provides a fixed start up delay of 72 ms, which delays the PIC until the operating voltage VDD rises to its full value. This operates on internal RC oscillator and the device will be in Reset state during this delay.

Brown-out Reset – BOR

Brown out is a drop in supply voltage so that our device will not function reliably. In PIC Microcontrollers Brown-out Reset is provided to reset the device when brown out condition occurs and can be enabled or disabled using Configuration Bits. If the supply voltage VDD drops below VBOR for time longer than TBOR, the brown out situation will reset the device. See your device datasheet to find values of VBOR and TBOR. After Brown-out Reset, the device will continue in this condition until the supply voltage VDD rises above VBOR.

Code and Data Protection

Code Protection feature allows us to protect our microcontroller program being copied by others. This feature is beneficial to Intellectual Property (IP) Vendors, Original Design/Original Equipment Manufactures (ODM/OEM) and Value Added Resellers (VAR). Appropriate bit(s) of Configuration Word register must be set to  make device in Code Protect mode. I am not mentioning it here as it is different for different microcontrollers, so please refer the datasheet of your microcontroller.

_CONFIG Directive Symbols from Microchip Header Files

Configuration Bit Symbols
Configuration Bit Symbols

If you are using Hi-Tech C, please refer your device include file (eg: pic16f877a.h) from the location C:\\Program Files (x86)\\HI-TECH Software\\PICC\\9.81\\include for corresponding _CONFIG Directive Symbols. They can define it in program in the following way.

__CONFIG(CP_OFF  & BOREN_OFF & WDTE_OFF & PWRTE_ON & FOSC_HS );

Share this post


>