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

Analog port pulls down

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



Joined: 22 Dec 2010
Posts: 5

View user's profile Send private message

Analog port pulls down
PostPosted: Fri Dec 24, 2010 4:56 am     Reply with quote

I'm trying to do an AD conversion on a pic16f88. I split the value I wish to measure in 1/60 using a 59k and 1k resistor and this seems to work: the input voltage on the AD port is 1/60th of the battery (0.14V in my case). However, as soon as I hook it up to the PIC (port RA0), the voltage gets pulled up. Using output_low() on this port results in a pull down to 0.07V. Why is this?

Code:

   setup_adc(ADC_CLOCK_INTERNAL);
   setup_adc_ports(sAN0 | VSS_VREF);


I also have a Vref of 2.5V split into 1/11th on port RA3 which does not get pulled up.
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Fri Dec 24, 2010 5:52 am     Reply with quote

As a comment, if your clock is faster than 1Mhz, look in the data sheet, and select the right ADC clock.....

On the pull down, when you do output_low, as soon as you do this, the TRIS will be programmed to 'output', and the pin will be pulled down.

Now, a question. Are you using, fast_io on this port?. If so, you have the TRIS set wrong. The pin needs to be set as an input. If not, are you are any time, using 'port wide' output instructions on the port (OUTPUT_A). If so, again the TRIS will be overridden and set incorrectly, but I'd have expected RA3 to also be affected.

Now another comment. Look at the _minimum_ Vref span for your chip. 0.227v (2.5/11), is _not_ suitable. Table 18-13, A20. If you use less than the specified span, accuracy just disappears.

Best Wishes
zzattack



Joined: 22 Dec 2010
Posts: 5

View user's profile Send private message

PostPosted: Fri Dec 24, 2010 6:14 am     Reply with quote

Thanks for your comment, I'm running the PIC at 8MHz,

I do not use any output_* or fast_io on this (or any other) port. Does the setup_adc_ports() command set the port to input itself, or do I need to do this manually myself too? I will no longer split the Vref. Anyway, I'm still measuring a high on the analog ports :(
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Dec 24, 2010 9:56 am     Reply with quote

All port pins are set to input by default. If you don't perform any port operations on RA0, there's no reason why it should change to high output state.
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