EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 593

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
- 577 -
sfr SPDAT = 0xcf;
sfr IE2 = 0xaf;
#define ESPI 0x02
sbit SS = P1^0;
sbit LED = P1^1;
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;
SS = 1;
SPCTL = 0x50; //Enable SPI master mode
SPSTAT = 0xc0; //Clear interrupt flag
while (1)
{
SS = 0; //Pull down the slave SS pin
SPDAT = 0x5a; //Send test data
while (!(SPSTAT & 0x80)); //Query completion flag
SPSTAT = 0xc0; //Clear interrupt flag
SS = 1; //Pull up the SS pin of the slave
LED = !LED; //Test port
}
}
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
P0M1 DATA 093H
P0M0 DATA 094H
P1M1 DATA 091H
P1M0 DATA 092H
P2M1 DATA 095H
P2M0 DATA 096H

Table of Contents

Related product manuals