Working with the the GO_DONE bit can be a hassle. Are you waiting a little bit for the cap to charge?, notice the nop's in the following code for a PIC10f220. It's not quite the same as the 16f876, maybe it will help. For the most part, the inbuilt a-d routine seems just fine.
'Start a-d conversion of internal 0.6V ref only
CHS1=1:CHS0=0
BSF ADCON0,ADON
nop:nop:nop:nop:nop:nop
BSF ADCON0,GO ;Start conversion
ADCPoll:
BTFSC ADCON0,NOT_DONE ;Is conversion done?
GOTO ADCPoll 'No, test again
'Result is complete and stored in ADRES
ADCON0 = 0
FVRpt6V = ADRES
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to use the Analog to Digital converter on the PIC 16F876.
Step 4 in the A/D section of the data sheet says:
"4. Start conversion:
• Set GO/DONE bit (ADCON0)"
NOTE: The DONE in GO/DONE has a Line over it.
To Set the bit I tried: BSF ADCON0, GO/DONE
But it did not work. I also tried replacing GO/DONE with GO or GO_DONE but this
did not work either.
How do you write a command in GCBASIC or Assembly language that will show the LINE over the DONE?
Working with the the GO_DONE bit can be a hassle. Are you waiting a little bit for the cap to charge?, notice the nop's in the following code for a PIC10f220. It's not quite the same as the 16f876, maybe it will help. For the most part, the inbuilt a-d routine seems just fine.
Thanks! Kent - That worked.