There seems to be a mistake, because the code did not work, and after my change, it did work.

 

MainLoop
    bsf        ADCON0,2        ;start conversion and wait for it to complete
    btfsc    ADCON0,2
    goto    $-2

 

goto $-2 is wrong, because it goes back 2 lines and starts the conversion all over again. You'll want to goto $-1 instead, to just test until the conversion is done.

 

However, I would reccommend this instead:

 

MainLoop
    bsf        ADCON0,2        ;start conversion and wait for it to complete

    wait_for_completion
    btfsc    ADCON0,2
    goto    wait_for_completion

 

Just to be safe. With the relative goto it could be a little confusing exactly where it jumps. With a label, there is no doubt. Of course, labels are annoying because you need unique names.

Views: 39

Comment

You need to be a member of Personal Mechatronics Lab to add comments!

Join Personal Mechatronics Lab

© 2023   Created by PML.   Powered by

Badges  |  Report an Issue  |  Terms of Service