View previous topic :: View next topic |
Author |
Message |
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
16f876 AN4 ADC hardware problem |
Posted: Sun Dec 13, 2009 3:58 pm |
|
|
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
|
|
Posted: Sun Dec 13, 2009 7:58 pm |
|
|
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
|
|
Posted: Mon Dec 14, 2009 3:34 am |
|
|
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! |
|
|
|