Wednesday, April 24, 2013

ADC library for PIC16F877A microcontroller

For the past one week I was on a hobby project using PIC16F877A. By this time I had written some useful APIs for configuring and using ADC in PIC16F877A, which I think is worth sharing.

This library is targeted for XC8 compiler. For this library to work prior to including "adc.h" header, you should define the macro _XTAL_FREQ to set the crystal frequency. It is preferred to define this macro in the project settings.

Download PIC16F877A ADC library

A sample program using the above library is given below. This program will read the analog input at channel 0 (AN0) of PIC16F877A. If the read value is greater than 512 (~2.5 volts), LED connected to the RD7 will be switched on. You can vary the analog input by varying the POT. To test this program you can use the same circuit given in the post PIC16F877A ADC example.

Download related MPLAB X IDE project files.

Note:
You are free to point out the mistakes and ask doubts.
Disclaimer:
Technoburst will not be responsible for any damages both physically or financially occurred due to the use of this circuit/program.

1 comments:

sahu said...

here define only 1 ADC Channel reading . pl enplane here more then 1 ADC Channel reading .

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes