Menu

PIC 16F876 A/D Converter

Help
MBB
2011-09-16
2013-05-30
  • MBB

    MBB - 2011-09-16

    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?

     
  • kent_twt4

    kent_twt4 - 2011-09-16

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

    MBB - 2011-09-18

    Thanks! Kent - That worked.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.