PDA

View Full Version : ADCIN with PIC18F4620



Brian J Walsh
- 3rd July 2008, 23:57
Does anyone know if ADCIN and its associated DEFINES work with the PIC18F4620?

As part of a migration from a 16F877 I noticed that the adcon registers are more numerous and somewhat different.

To check what was happening, I put in debug statements after the block of DEFINE ADC_.. statements and observed that the contents of adcon0,1 & 2 were all zero as though the DEFINES had had no effect. My DEFINES are genuinely upper case, which I believe is an MPASM requirement.

I have now set these registers directly (adconx = %xxxxxxxx) and the debug confirms that their contents are now as expected.

Subsequent ADCIN statements do not give the expected result and I wondered if I would have to abandon ADCIN and trigger the conversion manually by toggling GO/DONE in adcon0.

Any ideas? TIA,

Brian Walsh.

mackrackit
- 4th July 2008, 01:25
On the 18F4320 I do the toggle to get it working.
Here is the way I do it.


getT2:
ADCON0=$5
gosub getAD
temp2 = ADRESH
return

getAD:
pause 50
ADCON0.1 = 1
pause 50
return

And I have to set ADCON1 with the dec value: Example
ADCON1=13

But that is me:)