PIC ADC result register empty

Status
Not open for further replies.

col_implant

New Member
Hi,

I'm trying to use the PIC ADC for a simple detection circuit. I'm running the PIC via ICD2 in debug mode and examining the operation of the ADC.

I'm sure that I have the module set up correctly... I'm using channel An0, with Vss & Vdd references, right justified, with a conversion clock of fosc/8. I have double checked that the TRISA,0 bit is set as an input

ADCON0 = 0x01
ADCON1 = 0x0E
ADCON2 = 0x89

My ADIF interupt is working fine, and the GO/DONE bit (ADCON0,1) is going high. However the ADRES registers are showing zero value. I have measured the voltage at the An0 pin with a multimeter and confirmed it is not 0.

I have used the PIC ADC before without such issues. I'm wondering is there any other reason which I have overlooked why the result is zero.

Any help appreciated

Cheers

C
 
The full code is a huge program... here are the appropiate bits, hope this is enough

; routines within the main program so ADC conversion
call WaitForConversionStarted
call WaitForConversionDone
call StoreMeasurement ; store value

InitiateADconversion
bcf PIR2,CCP2IF ; clear interrupt flag
bsf Mail,2 ; indicate that conversion was started
bsf ADCON0,GO ; start conversion
nop
nop
bra EndInterrupt
; --------------------------------------------------------------------------------
WaitForConversionDone ; conversion done ?
btfsc ADCON0,1
bra WaitForConversionDone
bcf PIR1,ADIF ; clears ADC interrupt flag
return

; ------------------------------------------------------------------------------
WaitForConversionStarted ; conversion started ?
btfss Mail,2
bra WaitForConversionStarted
bcf Mail,2
return
; -----------------END OF INTERRUPT SERVICE ROUTINES ----------------------
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…