NJ Roadmap
New Member
I'm trying to sample a couple of analog inputs by getting the A/D on my PIC18F4520 to toggle between the two pins using the ADCON0, ADCON1 and ADCON2 registers. But somehow the values read don't seem to be the true analog values (I'm reading them off to an LCD), however if the pins are sampled on their own without the PIC toggling between the two inputs the readings are good. I've given a 20ms delay between pin toggles so that should be enough for the holding cap to recharge to the new pin's value. Even then the cap should eventually charge to the correct value. Any ideas? I'm stumpted. I'm using Vss and Vdd are Vref+ and Vref- for both pin measurements.
My ADCON settings are right, the only issue I can think of is that I'm using AN0 and AN6 as inputs as opposed to say AN0 and AN1, and hence I've had to set ADCON1 bits 3:0 so that AN0:AN6 are set as analog inputs but I don't see that as a problem, or is it one?
My ADCON settings are right, the only issue I can think of is that I'm using AN0 and AN6 as inputs as opposed to say AN0 and AN1, and hence I've had to set ADCON1 bits 3:0 so that AN0:AN6 are set as analog inputs but I don't see that as a problem, or is it one?