list p=16f877 include __CONFIG _PWRTE_ON&_HS_OSC&_LVP_ON&_WDT_OFF&_DEBUG_OFF TEMP equ 10h s3 equ 20h adif equ 1 adgo equ 2 ch2 equ 6 ch3 equ 7 flag equ 0C ADTABLE equ 20 org 00h goto start org 0x10 start movlw b'00000000' movwf PORTB tris PORTB bsf STATUS,RP0 movwf TRISB bcf STATUS,RP0 call initad banksel ADCON1 bsf ADCON1,adgo loop1 btfsc ADCON1,adgo goto loop1 goto update update banksel ADRESL movf ADRESL,w movwf 0 movlw ADTABLE subwf FSR,W btfss STATUS,Z goto NextAd movf ADRESL,w movwf PORTB NextAd call NextChannel call Delay banksel ADCON0 bcf ADCON0,adif banksel ADCON0 bsf ADCON0,adgo loop banksel ADCON0 btfsc ADCON0,adgo goto loop goto update initad bsf STATUS,RP0 movlw b'00000000' movwf ADCON1 bcf STATUS,5 movlw b'11000001' movwf ADCON0 movlw ADTABLE movwf FSR clrf ADRESH banksel TRISA clrf ADRESL banksel PORTA return NextChannel banksel ADCON0 movlw 0x08 addwf ADCON0,F bcf ADCON0,5 clrf TEMP btfsc ADCON0,3 bsf TEMP,0 btfsc ADCON0,4 bsf TEMP,1 movlw ADTABLE addwf TEMP,W movwf FSR return Delay movlw d'29' movwf s3 c1 decfsz s3 goto c1 return end