SN8P2740 Series
ADC, OP-amp, Comparator 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 113
Version 2.0
13.5 ADC OPERATION EXAMLPE
ADC CONFIGURATION:
; Reset ADC.
CLR
ADM
; Clear TC0M register.
; Set ADC clock rate and ADC resolution.
MOV
A, #0
nmn
0000b
; nn: ADCKS[1:0] for ADC clock rate.
B0MOV
ADR, A
; 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
P4CON, A
MOV
A, #
value2
; Set ADC input channel as input mode.
B0MOV
P4M, A
MOV
A, #
value3
; Disable ADC input channel
‟s internal pull-up resistor.
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
A, #
value
; Set ADCHS[2:0] for ADC input channel selection.
OR
ADM, A
; Enable ADC input channel.
B0BSET
FGCHS
; Enable ADC interrupt function.
B0BCLR
FADCIRQ
; Clear ADC interrupt flag.
B0BSET
FADCIEN
; 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.