EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Detect External Voltage or Battery Voltage Using ADC 15 Th Channel

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 498 -
ORL ADC_CONTR,#40H ; Start AD conversion
NOP
NOP
MOV A,ADC_CONTR ; Query ADC completion flag
JNB ACC.5,$-2
ANL ADC_CONTR,#NOT 20H ; Clear completion flag
MOV P2,ADC_RES ; Read ADC result
SJMP LOOP
END
17.5.5 Detect External Voltage or Battery Voltage using ADC 15th
Channel
The 15th channel of ADC in the STC8A8K64D4 family of microcontrollers is used to measure the internal
reference voltage. The internal reference voltage is stable, about 1.19V, and does not change with the chip's working
voltage. So you can measure the internal reference voltage and use it to deduce the external voltage or external battery
voltage through the value of the ADC.
The following figure is a reference circuit diagram:
47u 103
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P1.0
P1.1
P1.2
P1.6
P1.7
AGnd
AVref
AVcc
P5.4
Vcc
P5.5
Gnd
P4.5
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
P4.4
P4.2
P4.1
P3.7
P3.6
P3.5
P3.4
P3.3
P3.2
P3.1
P3.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
STC8A8K64D4
External or battery powered
Vin
Power On
Vcc
C language code
//Operating frequency for test is 11.0592MHz
#include "reg51.h"
#include "intrins.h"
#define FOSC 11059200UL
#define BRT (65536 - FOSC / 115200 / 4)
sfr AUXR = 0x8e;

Table of Contents

Related product manuals