I've been working with the 16F877A and haven't had any ADC problems. Now with the 18F4620 I can't seem to read any ADC voltages. I'm trying to monitor certain voltages including the voltage at the devices battery with and without external power supplied.
Here is my set up:
Assume only reading value on an 8.4 V LI-Poly battery.
Battery voltage is being sensed at the middle of a voltage divider
<< --- 10K --T -- 3.3K---Vss
Reading at the center of the above divider I would expect the max input voltage sensed (without damage to the PIC) is 20 Volts which would be sensed across the divider as as 1/4 of the input or 5VDC. My input may be 10 Volts max so I should expect to read about 2.5 VDC at the input to the ADC.
I'm using AN7 (RE2) as my analog input pin being connected to the center of the divider.
Here is the PBP code being used:
DEFINES-----------------------------------------------------------
define ADC_BITS 10
define ADC_CLOCK 3
define ADC_SAMPLESUS 50
define OSC 40
ROUTINE-----------------------------------------------------------
Chk_Volts:
TRISe.2 = 1
ADCON0 = %00011101
ADCON1 = %00000111
ADCON2 = %10111111
PAUSE 10
adcin 7, volts_10
pause 200
SEROUT LCD, LCD_Mode,[12, "Volts_10: ",#volts10," "]
----------------------------------------------------------------------
I have 7 new boards with the PIC18F4620 installed as described above. All functions work well except for ADC input. Never had problems doing almost the same thing with the 16F877A.
Any ideas out there as to what I am doing wrong?
John P, Virginia Beach, VA USA
Bookmarks