SN8P2740 Series
ADC, OP-amp, Comparator 8-Bit Micro-Controller
13.5 ADC OPERATION EXAMLPE
ADC CONFIGURATION:
; Reset ADC.
CLR
ADM
; Clear TC0M register.
; Set ADC clock rate and ADC resolution.
MOV
B0MOV
A, #0nmn0000b
ADR, A
; nn: ADCKS[1:0] for ADC clock rate.
; m: ADLEN for ADC reolution.
; Set ADC high reference voltage source.
B0BCLR
FAVREFH
; Internal Vdd.
or
B0BSET
FAVREFH
; External reference voltage.
; Set ADC input channel configuration.
MOV
A, #value1
; Set P4CON for ADC input channel.
B0MOV
MOV
B0MOV
MOV
P4CON, A
A, #value2
P4M, A
; Set ADC input channel as input mode.
; Disable ADC input channel‟s internal pull-up resistor.
A, #value3
B0MOV
P4UR, A
; Enable ADC.
B0BSET
FADCENB
; Execute ADC 100us warm-up time delay loop.
CALL
100usDLY
; 100us delay loop.
; Select ADC input channel.
MOV
OR
A, #value
ADM, A
; Set ADCHS[2:0] for ADC input channel selection.
; Enable ADC input channel.
B0BSET
FGCHS
; Enable ADC interrupt function.
B0BCLR
B0BSET
FADCIRQ
FADCIEN
; Clear ADC interrupt flag.
; Enable ADC interrupt function.
; Start to execute ADC converting.
B0BSET FADS
Note:
1.
When ADENB is enabled, the system must be delay 100us to be the ADC warm-up time by
program, and then set ADS to do ADC converting. The 100us delay time is necessary after
ADENB setting (not ADS setting), or the ADC converting result would be error. Normally, the
ADENB is set one time when the system under normal run condition, and do the delay time
only one time.
2.
In power saving situation like power down mode and green mode, and not using ADC function,
to disable ADC by program is necessary to reduce power consumption.
SONiX TECHNOLOGY CO., LTD
Page 113
Version 2.0