|
|
View previous topic :: View next topic |
Author |
Message |
Einly
Joined: 10 Sep 2003 Posts: 60
|
read 10 bit ADC on PIC16f876 |
Posted: Sun Jun 19, 2005 9:50 pm |
|
|
Dear all,
Does anyone have an example of how to use the 10 bit adc on PIC16f876? Previously, I am using the ADC, but instead of 10 bit, I only read 8 bit. May I know how does the program look like, if I want to read all the 10 bits? Thanks. _________________ Einly |
|
|
valemike Guest
|
|
Posted: Sun Jun 19, 2005 10:08 pm |
|
|
For devices that do have the 10-bit resolution in the A/D, you simply type the following statement at the top of your .c file:
Code: |
#include <18F2620.h>
#device ADC=10
#fuses MCLR,HS,WDT4096,NOPROTECT,NOLVP,NOXINST,PUT
...
|
Above, my statement ADC=10 means i want to use 10-bit A/D. If you wanted to use 8-bit A/D, then type ADC=8
-Mike |
|
|
valemike Guest
|
p.s. |
Posted: Sun Jun 19, 2005 10:10 pm |
|
|
If you want to make an A/D reading, you would store it in an "unsigned long" or int16:
Code: |
unsigned long this_reading; // assumes ADC=10
this_reading = read_adc();
~~~~~~~~~
unsigned int this_reading; // assumes ADC=8
this_reading = read_adc();
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|