PIC16F688
EXAMPLE 8-1:
A/D CONVERSION
;This code block configures the ADC
;for polling, Vdd reference, Frc clock
;and AN0 input.
;
;Conversion start & polling for completion
; are included.
;
BANKSEL ADCON1
;
MOVLW
MOVWF
B’01110000’ ;ADC Frc clock
ADCON1
;
BANKSEL TRISA
;
BSF
TRISA,0
;Set RA0 to input
BANKSEL ANSEL
;
BSF
ANSEL,0
;Set RA0 to analog
;
BANKSEL ADCON0
MOVLW
MOVWF
CALL
BSF
BTFSC
GOTO
B’10000001’ ;Right justify,
ADCON0
;Vdd Vref, AN0, On
;Acquisiton delay
;Start conversion
;Is conversion done?
;No, test again
;
SampleTime
ADCON0,GO
ADCON0,GO
$-1
BANKSEL ADRESH
MOVF
MOVWF
BANKSEL ADRESL
ADRESH,W
RESULTHI
;Read upper 2 bits
;store in GPR space
;
MOVF
MOVWF
ADRESL,W
RESULTLO
;Read lower 8 bits
;Store in GPR space
DS41203D-page 70
© 2007 Microchip Technology Inc.