piclist 2002\08\22\195147a >
Thread: cycling through A/D channels
www.piclist.com/techref/microchip/ios.htm?key=a%2Fd
face picon face BY : Jinx email (remove spam text)



> and using a different combo of bcf/bsf for each channel. It doesn't
> seem very efficient though

I use macros, which at least makes the text a little easier to work with,
although I'm not cycling through them 0-7. If I was, my code would look
something like

adch0  macro
        bcf    adcon0,chs0
        bcf    adcon0,chs1
        bcf    adcon0,chs2
        endm

adch1  macro
        bsf    adcon0,chs0
        bcf    adcon0,chs1
        bcf    adcon0,chs2
        endm

adch2  macro
        bcf    adcon0,chs0
        bsf    adcon0,chs1
        bcf    adcon0,chs2
        endm

adch3  macro
        bsf    adcon0,chs0
        bsf    adcon0,chs1
        bcf    adcon0,chs2
        endm

adch4  macro
        bcf    adcon0,chs0
        bcf    adcon0,chs1
        bsf    adcon0,chs2
        endm

adch5  macro
        bsf    adcon0,chs0
        bcf    adcon0,chs1
        bsf    adcon0,chs2
        endm

adch6  macro
        bcf    adcon0,chs0
        bsf    adcon0,chs1
        bsf    adcon0,chs2
        endm

adch7  macro
        bsf    adcon0,chs0
        bsf    adcon0,chs1
        bsf    adcon0,chs2
        endm

        adch0
        acquisition delay
        bsf     adcon0,go_done ;start conversion
        nop
        nop
        call    getdata
        call    do.something.with.data

        adch1
        acquisition delay
        bsf     adcon0,go_done ;start conversion
        nop
        nop
        call    getdata
        call    do_something_with_data

etc

;--------------------------

getdata

        btfsc   adcon0,go_done
        goto    $-1
        movf    adresh,w
        movwf   hi
        bank1
        movf    adresl,w
        bank0
        movwf   lo
        return

repeated for adch2 to adch7, using fsr to store the conversion data in
RAM. If you used a bit manipulation routine to cycle through the channel
select bits I'm not sure you'd gain much. It would / might take less memory
but would possibly take longer. Depends what you call "inefficient" - time
or code space ? You could integrate the "do_something_with_data"
routine into the acquisition or conversion time, which would make the
cycling "more efficient"

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


<000a01c24a36$b6e14060$1f9fa7cb@joe> 7bit

See also: www.piclist.com/techref/microchip/ios.htm?key=a%2Fd
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) cycling through A/D channels

month overview.

new search...