PIC 16F877A Tutorial for Beginners

Tutorial for Beginners:

        This post provides the method to set configuration bits in the code for PIC16F877 microcontroller. You have to set configuration bits in order to make PIC microcontroller work correctly. Here I am going to explain the procedure of selecting configuration bits for PIC16F877. A typical example code for setting configuration bits in the code (using MPLAB + HI-TECH C compiler) is also provided. Following steps are required to setup configuration bits for PIC16F877.

Step 1:
The first step to start writing the configuration bits is to check "Special Features of the CPU" section in the datasheet of PIC16F877. In this section, first chapter is about "Configuration bits". You should read this section and identify what values you want to put in the configuration register.

Step 2:
Open the file "pic16f877.h" from the directory "C:\Program Files\HI-TECH Software\PICC\9.83\include". In the start of this file configuration bit macros are defined. Snapshot of these macros is shown below.
Config Bits.
Step 3:
Here we have to choose appropriate macros to be used in the code to set configuration bits correctly. For each configuration bit we have a choice between some macros. For example, for watchdog timer enable bit, we have a choice between WDTE_ON or WDTE_OFF. If we want to enable the watchdog timer, then WDTE_ON macro should be used in the code. But if we want to disable watchdog, then WDTE_OFF macro should be used in the code to set the configuration bit accordingly. Similarly, you can select appropriate macros for other configuration bits.


You can leave your comments in the comment section below.

Downloads

LCD interfacing code using PIC16F877a was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. 
To download code and Proteus simulation Click Here .


Comments

Popular Posts