SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 119
Version 1.7
Example: Fast ADC conversion Rate setting
@CPREG_Init:
B0BSET
FBGRENB
;Enable Band Gap Reference voltage
@AVDDR_Enable: B0BSET
FAVDDRENB
; Enable AVDDR Voltage=2.4V
@VDD_Detection:
@PGIA_Init:
MOV
A, #01010101B
B0MOV
CHS, A
; PGIA differential channel (VDD+, VDD-) and PGIA Gain x 1
MOV
A, #00010000B
; Set VDD detection function
B0MOV
AMPM, A
; Set PGIA buffer off and PGIA chopper 31.25KHz
B0BCLR
FAMPENB
;
Disable PGIA function
; V (X+, X-) Output = V (VDD+, VDD-) x 1
@ADC_Init:
MOV
A, #01101000B
B0MOV
ADCM1, A
; ADC Reference voltage = internal 0.84V, ADC_Gain = 1x.
MOV
A, #00100110B
B0MOV
ADCM2, A
; Set ADC clock=250kHz, OSR=256, offset=0V. WR=~1KHz
B0BSET
FADCENB
; Enable ADC function
Call
Wait_500uS
; Wait 500us for Regulators and analog function stable
@ADC_Wait:
B0BTS1
FDRDY
; Check ADC output new data or not
JMP
@ADC_Wait
; Wait for Bit DRDY = 1
@ADC_Read:
B0BCLR
FDRDY
; Output ADC conversion word
B0MOV
A, ADCDH
B0MOV
Data_H_Buf, A
; Move ADC conversion High byte to Data Buffer
B0MOV
A, ADCDM
B0MOV
Data_M_Buf, A
; Move ADC conversion Medium byte to Data Buffer
Example: Green Mode and Sleep Mode setting
Green_Mode_1:
// Wakeup By ADC ready, T0 overflow and P0 level change.
MOV
A, #11110000
B0MOV
T0M, A
; T0 overflow and wakeup every 512us. (Fcpu = 1MIP)
MOV
A, #00100110B
B0MOV
ADCM2, A
; Set ADC clock=250kHz, OSR=256. WR=976Hz
B0BSET
FADCENB
; Enable ADC and ADC wakeup system every 1024us.
GreenMode
; System into Green mode. (Macro)
Green_Mode_2:
// Wakeup by T0 overflow and P0 level change. (Current 3uA typ.)
B0BSET
FLCKMD
; Into slow mode.
B0BSET
FSTPHX
; Stop High clock (IHRC).
MOV
A, #11000000
B0MOV
T0M, A
; T0 overflow and green mode wakeup every 0.5s.
B0BCLR
FLBTENB
; Disable Low battery detect function.
B0BCLR
FAMPENB
; Disable PGIA function.
B0BCLR
FADCENB
; Disable ADC function.
B0BCLR
FAVDDRENB
; Disable AVDDR.
B0BCLR
FLCDENB
; Disable LCD display.
B0BCLR
FBGRENB
; Disable Band Gap Voltage.
GreenMode
; System into Green mode. (Macro)