STC8A8K64D4 Series Manual
-
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
P_SW2 = 0x00; //Wake up MCU on the falling edge of SDA/P1.4
// P_SW2 = 0x10; //Wake up MCU on the falling edge of SDA_2/P2.4
// P_SW2 = 0x30; //Wake up MCU on the falling edge of SDA_4/P3.3
P_SW2 |= 0x80;
I2CCFG = 0x80; //Enable slave mode of I2C module
I2CSLCR = 0x40; //Enable start signal interrupt
EA = 1;
PCON = 0x02; //MCU enters power-down mode, it will not enter the interrupt service
routine after power-down wake-up
_nop_();
_nop_();
_nop_();
_nop_();
while (1)
{
P11 = ~P11;
}
}
Assembly code
; Operating frequency for test is 11.0592MHz
P_SW2 DATA 0BAH
I2CCFG XDATA 0FE80H
I2CSLCR XDATA 0FE83H
I2CSLST XDATA 0FE84H
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 00C3H
LJMP I2CISR