CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

read 10 bit ADC on PIC16f876

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Einly



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

read 10 bit ADC on PIC16f876
PostPosted: Sun Jun 19, 2005 9:50 pm     Reply with quote

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







PostPosted: Sun Jun 19, 2005 10:08 pm     Reply with quote

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.
PostPosted: Sun Jun 19, 2005 10:10 pm     Reply with quote

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();

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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