SN8P275X Series
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 140
Version 0.7
11.7 ADC ROUTINE EXAMPLE
¾
Example : Configure AIN0 as 12-bit ADC input and start ADC conversion then enter power down mode.
ADC0:
B0BSET
FADENB
; Enable ADC circuit
CALL
Delay100uS
; Delay 100uS to wait ADC circuit ready for conversion
MOV
A,
#0FEh
B0MOV
P4UR, A
; Disable P4.0 pull-up resistor
B0BCLR
FP40M
; Set P4.0 as input pin
MOV
A,
#01h
B0MOV
P4CON, A
; Set P4.0 as pure analog input
MOV
A,
#60H
B0MOV
ADR, A
; To set 12-bit ADC and ADC clock = Fosc.
MOV
A,#90H
B0MOV
ADM,A
; To enable ADC and set AIN0 input
B0BSET
FADS
; To start conversion
WADC0:
B0BTS1
FEOC
; To skip, if end of converting =1
JMP
WADC0
; else, jump to WADC0
B0MOV
A,ADB
; To get AIN0 input data bit11 ~ bit4
B0MOV
Adc_Buf_Hi,
A
B0MOV
A,ADR
; To get AIN0 input data bit3 ~ bit0
AND
A,
0Fh
B0MOV
Adc_Buf_Low,
A
Power_Down .
.
B0BCLR
FADENB
; Disable ADC circuit
B0BCLR
FCPUM1
B0BSET
FCPUM0
; Enter sleep mode