list p=16f877,f=inhX32, x=off
include <p16f877.inc>
;free dev/debug regs 20 to 27
errorlevel -302
__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF & _LVP_OFF
org 0x000
goto start
org 0x004
start
call initial
again
call startconv
call check
call result
goto again
initial
BCF STATUS,RP1
BSF STATUS,RP0
MOVLW b'00000001'
MOVWF TRISA
MOVLW b'00000000'
MOVWF TRISB
MOVLW b'00000000'
MOVWF TRISC
MOVLW b'00000000'
MOVWF TRISD
MOVLW b'10001110';rj,dddddd,a
MOVWF ADCON1
BCF STATUS,RP1
BCF STATUS,RP0
MOVLW b'10000001';osc/32,..... adon
MOVWF ADCON0
RETURN
startconv:
BSF ADCON0,GO
RETURN
check:
BTFSS PIR1,ADIF
goto check
;;MOVLW b'00000001'
;;MOVWF PORTC
BCF PIR1,ADIF
return
result:
BCF STATUS,RP1
BSF STATUS,RP0
MOVF ADRESL,W; ****
BCF STATUS,RP0;*****
MOVWF PORTB
BCF STATUS,RP1
BCF STATUS,RP0
MOVF ADRESH,W;*****
MOVWF PORTD
RETURN
END