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

16f88 adc problem

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



Joined: 15 Apr 2007
Posts: 1

View user's profile Send private message

16f88 adc problem
PostPosted: Sun Apr 15, 2007 2:57 am     Reply with quote

Hi,

I am trying to read an lm35 temperature sensor with the 16f88. It works very well if I setup the adc as:
setup_port_a( sAN0|VSS_VDD );

But then I would like to use the internal vref in order to have a different reading range, as the sensor gives 10mv/C.

If I try this code:

setup_vref(VREF_HIGH);
setup_port_a( sAN0|VSS_VREF );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );

then any reading of the adc gives 1023. The same if I try with VREF_HIGH|5) or any other number.

What am I doing wrong???

Regards,
Aldo
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 5:28 am     Reply with quote

I think that you are confusing the comparator reference and the adc reference.
The comparator reference is separate from the comparator setup and can be output on RA2,
but in adc mode this is the external Vref- input, not what is needed.

An external reference is needed on RA3 (Vref+ in adc mode) to do what you want.

So the setup is then sAN0|VSS_VREF - this gives a range of 0 to Vref volts.
Guest








PostPosted: Sun Apr 15, 2007 9:15 am     Reply with quote

Hi,

you could not possibly any more right... after two days struggling, I undersood my mistake some 15 minutes after posting the message! Now I am feeding an external vref and it works fine. Thank you, anyhow.

Regards
Aldo
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