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: