STC8A8K64D4 Series Manual
-
MAIN:
MOV SP, #5FH
MOV P0M0, #00H
MOV P0M1, #00H
MOV P1M0, #00H
MOV P1M1, #00H
MOV P2M0, #00H
MOV P2M1, #00H
MOV P3M0, #00H
MOV P3M1, #00H
MOV P4M0, #00H
MOV P4M1, #00H
MOV P5M0, #00H
MOV P5M1, #00H
MOV CMPCR2,#00H
MOV CMPCR1,#80H ;Enable comparator module
ORL CMPCR1,#30H ;Enable edge interrupt of comparator
ANL CMPCR1,#NOT 08H ;P3.6 is CMP + input pin
ORL CMPCR1,#04H ;P3.7 is CMP- input pin
ORL CMPCR1,#02H ;Enable Comparator output
SETB EA
MOV PCON,#02H ;MCU enters power-down mode
NOP ;Enter interrupt service routine immediately after wake-up from power mode
NOP
NOP
NOP
LOOP:
CPL P1.1
JMP LOOP
END
6.7.14 Detect the Operating Voltage (Battery Voltage) using LVD
If you need to use LVD to detect the battery voltage, you need to remove the low-voltage reset function when downloading
from the ISP, as shown in the following figure.
(It is recommended to use the 15th channel of ADC to detect battery voltage, see ADC chapter)
C language code
// Operating frequency for test is 11.0592MHz
#include "reg51.h"
#include "intrins.h"
#define FOSC 11059200UL