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 support@ccsinfo.com

ADC_read()

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







ADC_read()
PostPosted: Wed Feb 22, 2006 2:06 pm     Reply with quote

I have use this function to read the voltage value from channel 0. I don't know that if I use
float value;
value = adc_read();

printf("%f", value);

after this executed it will return 2.5 or something else if my apply 2.5 V to channel 0. Can anyone help?
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Wed Feb 22, 2006 2:20 pm     Reply with quote

adc_read does not return a float value, it returns a hex value. If you have selected an 8-bit ADC, then it will return 0xFF if the pin is 5V and 0x00 if there is 0V on the pin, etc.. You have to perform the math on the hex value to turn it back into a voltage.
_________________
The difference between genius and stupidity is that genius has its limits...
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