EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 602

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
- 586 -
MOV SPCTL,#40H ;Enable SPI slave mode and standby
MOV SPSTAT,#0C0H ;Clear interrupt flag
LOOP:
JB KEY,SKIP ;Wait for the key to trigger
MOV SPCTL,#50H ;Enable SPI master mode
CLR SS ;Pull down the slave SS pin
MOV SPDAT,#5AH ;Send test data
JNB KEY,$ ;Wait for the keys to be released
SKIP:
MOV A,SPSTAT
JNB ACC.7,LOOP
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
CPL LED
JMP LOOP
MASTER:
SETB SS ;Pull up the SS pin of the slave
MOV SPCTL,#40H ;Reset to slave and standby
CPL LED
JMP LOOP
END

Table of Contents

Related product manuals