• 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.

PIC16F819 - Problem with the A/D module

Not open for further replies.


Hi to all!

I have recently started to experiment a little bit with a PIC16F819 and I have problems with the operation of the A/D module.

I have attached the .asm file that I use.

It seems that after the A/D finishes with the conversion, the ADRESH and ADRESL registers are not updated with the result of the conversion and I don`t understand what I am doing wrong.

Actually, as you can see in the code, before the result is ready, I set the contents of both ADRESH and ADRESL to the value of 0x0F. The most logical behavior would be that after the A/D conversion -at least- one of these registers has a different content (I choose to display to PORTB -some LEDs- the ADRESH with the DISPLAY subroutine).

However, the final result is that PORTB has 0x0F!! So it seems that whatever the result of the A/D is, the ADRESH has not changed at all.

Does anyone have any good idea about this?

P.S. : Note that this test with the registers and the value 0x0F is just to investigate what the problem is. My initial code didn't include this part, but still didn't work properly

Thanks in advance,



Well-Known Member
Most Helpful Member
I suggest that you tidy up your code. Remove all the parts not needed for the ADC and see if you can get it working. One thing you definitely shouldn't do is write to the ADC result registers after starting a conversion.



Well-Known Member
All you really need after set your chip up to use ADC is this to out put to led say on PORTB
     call	adcdelay		  ;delay to charge cap
     bsf       ADCON0,GO      ; start conversion
     btfss     ADCON0,GO      ; this bit will change to zero when the conversion is complete
     goto      $-1
    movf     ADRESH,w       ; Copy the display to the LEDs
    movlw  PORTB             ; send it out to portB


I guess you both have right. I was trying to implement my final application, but moved away from my short-term goal which is simply to get the A/D working!

And Pommie, I think that what you said about not writing the ADC result register after starting the conversion must be the real reason for this behavior I observe. However, I thought that this wouldn't matter, because the data sheet says that these registers are not updated until the conversion has finished.

Anyway, thanks a lot both of you for your help and for your quick reply. I'll try to simplify things and come back if I still face a problem.
Not open for further replies.

Latest threads

EE World Online Articles