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

16f876 AN4 ADC hardware problem

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



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

16f876 AN4 ADC hardware problem
PostPosted: Sun Dec 13, 2009 3:58 pm     Reply with quote

I'm using:
PIC 16F876A
SETUP_ADC_PORTS(ALL_ANALOG);
compiler version PCW 4.057
Real hardware with 4,7k trimmer to simulate inputs.

Pin number 7 is RA5/AN4
Code:
     set_adc_channel(PIN_A5);
     delay_us(20);
     soglia = read_adc();

When the trimmer is disconnected from pin 7, I can generate a voltage from 0 to 5 V continuosly.
After having connect the trimmer with the pin 7 the voltage is very low (less thah half Volt) and became 5V justs in the rotation end.

It looks like to have a too low input impedance....
Can be a wrong firmware setup?
All the other analog inputs works properly.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 13, 2009 7:58 pm     Reply with quote

Quote:
set_adc_channel(PIN_A5);

That's not how you set the channel. The channel parameter is a number
from 0 to the maximum A/D channel. This is in the CCS manual.
For example, pin RA5 is the AN4 analog input pin. Therefore, it's A/D
channel 4, so give the set_adc_channel() function a parameter of 4.
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

PostPosted: Mon Dec 14, 2009 3:34 am     Reply with quote

ah, the problem was a wrong tris_a configuration
RA5/AN4 was configured as output
set_tris_a(0x3F); //0011 1111 ra7...ra0
I have solve, and correct mistakes.

thanks!
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