STC8A8K64D4 Series Manual
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOVX
MOV
MOV
MOV
ORL
NOP
NOP
MOV
JNB
ANL
MOV
MOV
MOV
;
MOV
;
MOV
;
MOV
SJMP
END
17.5.4 ADC converts multiple times to take average automatically
C language code
//Operating frequency for test is 11.0592MHz
#include "reg51.h"
#include "intrins.h"
sfr
ADC_CONTR
=
sfr
ADC_RES
=
sfr
ADC_RESL
=
sfr
ADCCFG
=
P0M0, #00H
P0M1, #00H
P1M0, #00H
P1M1, #00H
P2M0, #00H
P2M1, #00H
P3M0, #00H
P3M1, #00H
P4M0, #00H
P4M1, #00H
P5M0, #00H
P5M1, #00H
P1M0,#00H
P1M1,#01H
P_SW2,#80H
DPTR,#ADCTIM
A,#3FH
@DPTR,A
P_SW2,#00H
ADCCFG,#0FH
ADC_CONTR,#80H
ADC_CONTR,#40H
A,ADC_CONTR
ACC.5,$-2
ADC_CONTR,#NOT 20H
ADCCFG,#00H
A,ADC_RES
B,ADC_RESL
;B[7: 6] stores the lower 2 bits of the 10-bit ADC result, B [5: 0] is 0
ADCCFG,#20H
A,ADC_RES ;A [1: 0] stores the upper 2 bits of the 10-bit result of the ADC, and A [7: 2] is 0
B,ADC_RESL
$
0xbc;
0xbd;
0xbe;
0xde;
;Set P1.0 as ADC input
; Set ADC internal timing
;Set the ADC clock to the system clock/2/16
;Enable ADC module
;Start AD conversion
;Query ADC completion flag
;Clear completion flag
;Set result to align left
;A stores the upper 8 bits of the ADC
;Set result to align right
;B stores the lower 8 bits of the ADC's 10-bit result
'
s 10-bit result
- 495 -
Need help?
Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?