PDA

View Full Version : 5v on analog pin but reads value



jmgelba
- 9th November 2012, 03:41
Known working code for a 18F1320 and known working PCBs yet somehow theres 5v on an analog pin. Occuring on all tested pcbs. Its connected through a 100k resistor to a cathode of an led/0.5 ohm current sense resistor which goes to ground. This pulls the 5v to 0.2v. However the problem is the ADC voltage now has an offset of 0.2v which totally screws up current limiting.

Here's the ADC setup code:


Adcon0 = %00000001
Adcon1 = %01111000
Adcon2 = %10000011

Trisa = %11100111
Trisb = %10000011


The pin with the issue is an0 on pin1. I haven't tested over ADC pins for the same issue yet. I can't see a mistake with that setup code and here is no short on the PCB. I must have missed something. If you setup the ADC do the weak pullups have to be turned off?