EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 598

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 582 -
SPCTL = 0x40; //Enable SPI slave modeand standby
SPSTAT = 0xc0; //Clear interrupt flag
IE2 = ESPI; //Enable SPI interrupt
EA = 1;
while (1)
{
if (!KEY) //Wait for the key to trigger
{
SPCTL = 0x50; //Enable SPI master mode
SS = 0; //Pull down the slave SS pin
SPDAT = 0x5a; //Send test data
while (!KEY); //Wait for the keys to be released
}
}
}
Assembly code
;Operating frequency for test is 11.0592MHz
SPSTAT DATA 0CDH
SPCTL DATA 0CEH
SPDAT DATA 0CFH
IE2 DATA 0AFH
ESPI EQU 02H
SS BIT P1.0
LED BIT P1.1
KEY BIT P0.0
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 004BH
LJMP SPIISR
ORG 0100H
SPIISR:
PUSH ACC
MOV SPSTAT,#0C0H ;Clear interrupt flag
MOV A,SPCTL
JB ACC.4,MASTER
SLAVE:
MOV SPDAT,SPDAT ;Transmit the received data back to the master

Table of Contents

Related product manuals