• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC ADC result register empty

Not open for further replies.


New Member

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




New Member
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

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

; ------------------------------------------------------------------------------
WaitForConversionStarted ; conversion started ?
btfss Mail,2
bra WaitForConversionStarted
bcf Mail,2
; -----------------END OF INTERRUPT SERVICE ROUTINES ----------------------
Not open for further replies.

Latest threads

EE World Online Articles