STC8A8K64D4 Series Manual
#define
ESPI
sfr
P0M1
=
sfr
P0M0
=
sfr
P1M1
=
sfr
P1M0
=
sfr
P2M1
=
sfr
P2M0
=
sfr
P3M1
=
sfr
P3M0
=
sfr
P4M1
=
sfr
P4M0
=
sfr
P5M1
=
sfr
P5M0
=
sbit
SS
=
sbit
LED
=
sbit
KEY
=
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
LED = 1;
KEY = 1;
SS = 1;
SPCTL = 0x40;
SPSTAT = 0xc0;
while (1)
{
if (!KEY)
{
SPCTL = 0x50;
SS = 0;
SPDAT = 0x5a;
while (!KEY);
}
if (SPSTAT & 0x80)
{
SPSTAT = 0xc0;
if (SPCTL & 0x10)
{
SS = 1;
SPCTL = 0x40;
}
0x02
0x93;
0x94;
0x91;
0x92;
0x95;
0x96;
0xb1;
0xb2;
0xb3;
0xb4;
0xc9;
0xca;
P1^0;
P1^1;
P0^0;
//Enable SPI slave mode and standby
//Clear interrupt flag
//Wait for the key to trigger
//Enable SPI master mode
//Pull down the slave SS pin
//Send test data
//Wait for the keys to be released
//Clear interrupt flag
//Master mode
//Pull up the SS pin of the slave
//Reset to slave and standby
- 584 -
Need help?
Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?