STC8A8K64D4 Series Manual
-
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
CMPCR2 = 0x00;
CMPCR1 = 0x80; //Enable comparator module
CMPCR1 |= 0x30; //Enable edge interrupt of comparator
CMPCR1 &= ~0x08; //P3.6 is CMP + input pin
CMPCR1 |= 0x04; //P3.7 is CMP- input pin
CMPCR1 |= 0x02; //Enable Comparator output
EA = 1;
PCON = 0x02; //MCU enters power-down mode
_nop_(); //Enter interrupt service routine immediately after wake-up from power mode
_nop_();
_nop_();
_nop_();
while (1)
{
P11 = ~P11;
}
}
Assembly code
; Operating frequency for test is 11.0592MHz
CMPCR1 DATA 0E6H
CMPCR2 DATA 0E7H
P0M1 DATA 093H
P0M0 DATA 094H
P1M1 DATA 091H
P1M0 DATA 092H
P2M1 DATA 095H
P2M0 DATA 096H
P3M1 DATA 0B1H
P3M0 DATA 0B2H
P4M1 DATA 0B3H
P4M0 DATA 0B4H
P5M1 DATA 0C9H
P5M0 DATA 0CAH
ORG 0000H
LJMP MAIN
ORG 00ABH
LJMP CMPISR
ORG 0100H
CMPISR:
ANL CMPCR1,#NOT 40H ;Clear interrupt flag
CPL P1.0 ;Test port
RETI