SN8F2280 Series
USB 2.0 Full-Speed 8-Bit Micro-Controller
12.7 ADC CONTORL NOTICE
12.7.1 ADC SIGNAL
The ADC high reference voltage is internal Vdd. The ADC low reference voltage is ground.
The ADC input signal voltage range must be from high reference voltage to low reference voltage.
12.7.2 ADC PROGRAM
The first step of ADC execution is to setup ADC configuration. The ADC program setup sequence and notices are as
following.
z
Step 1: Enable ADC. ADENB is ADC control bit to control. ADENB = 1 is to enable ADC. ADENB = 0 is to disable
ADC. 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.
z
Step 2: Select the ADC input pin by CHS[2:0], enable P4CON’s related bit for the ADC input pin, and enable ADC
global input. When one AIN pin is selected to be analog signal input pin, it is necessary to setup the pin as
input mode and disable the pull-up resistor by program. Also to set the P4CON, and the digital I/O
function including pull-up is isolated.
z
z
Step 3: Start to execute ADC conversion by setting ADS = 1.
Step 4: Wait the end of ADC converting through checking EOC = 1 or ADCIRQ = 1. If enable ADC interrupt
function, the program executes ADC interrupt service when ADC interrupt occurrence. ADS is cleared when the
end of ADC converting automatically. EOC bit indicates ADC processing status immediately and is
cleared when ADS = 1. Users needn’t to clear it by program.
¾
Example : Configure AIN0 as 12-bit ADC input and start ADC conversion then enter power down mode.
ADC0:
B0BSET
CALL
MOV
B0MOV
B0BCLR
MOV
B0MOV
MOV
FADENB
Delay100uS
A, #0FEh
P4UR, A
FP40M
A, #01h
P4CON, A
A, #60H
ADR, A
; Enable ADC circuit
; Delay 100uS to wait ADC circuit ready for conversion
; Disable P4.0 pull-up resistor
; Set P4.0 as input pin
; Set P4.0 as pure analog input
B0MOV
MOV
; To set 12-bit ADC and ADC clock = Fosc.
A,#90H
B0MOV
B0BSET
ADM,A
FADS
; To enable ADC and set AIN0 input
; To start conversion
WADC0:
B0BTS1
JMP
B0MOV
B0MOV
B0MOV
AND
FEOC
WADC0
A,ADB
Adc_Buf_Hi, A
A,ADR
A, 0Fh
; To skip, if end of converting =1
; else, jump to WADC0
; To get AIN0 input data bit11 ~ bit4
; To get AIN0 input data bit3 ~ bit0
B0MOV
.
Adc_Buf_Low, A
.
Power_Down
B0BCLR
B0BCLR
B0BSET
FADENB
FCPUM1
FCPUM0
; Disable ADC circuit
; Enter sleep mode
SONiX TECHNOLOGY CO., LTD
Page 132
Version 1.1