T
The Saccullo's
Any help in understanding how to use the A2D would be welcome. Tried this
without using interrupts but it does not work
;setup for AD
bsf STATUS,RP0 ;bank 1
movlw b'00010001' ;set IO 0 to analog, use /8 clock
movwf ANSEL
bcf STATUS,RP0 ;bank 0
movlw b'00000001' ;turn A/D on,
movwf ADCON0
TurnOnAD
movlw b'00000010' ; turn A/D on, look for input
movwf ADCON0
ADLoop
btfsc ADCON0,1
goto ADLoop
movfw ADRESH ;test value from A/D
sublw .22 ;91 dec left shifted 2
btfsc STATUS,C ;use carry bit for test
goto TurnOnAD ;less than 22 assume zero value
continue
without using interrupts but it does not work
;setup for AD
bsf STATUS,RP0 ;bank 1
movlw b'00010001' ;set IO 0 to analog, use /8 clock
movwf ANSEL
bcf STATUS,RP0 ;bank 0
movlw b'00000001' ;turn A/D on,
movwf ADCON0
TurnOnAD
movlw b'00000010' ; turn A/D on, look for input
movwf ADCON0
ADLoop
btfsc ADCON0,1
goto ADLoop
movfw ADRESH ;test value from A/D
sublw .22 ;91 dec left shifted 2
btfsc STATUS,C ;use carry bit for test
goto TurnOnAD ;less than 22 assume zero value
continue