Datasheet
125
AT89C5132
4173C–USB–07/04
Slave Mode with Interrupt
Policy
Figure 101 shows the initialization phase and the transfer phase flows using the inter-
rupt policy.
The transfer format depends on the master controller.
Reading SPSTA at the beginning of the ISR is mandatory for clearing the SPIF flag.
Clear is effective when reading SPDAT.
Figure 103. Slave SPI Interrupt Policy Flows
Registers Table 98. SPCON Register
SPCON (S:C3h) – SPI Control Register
SPI Initialization
Interrupt Policy
Enable Interrupt
ESPI =1
SPI Interrupt
Service Routine
Select Slave Mode
MSTR = 0
Select Format
Program CPOL & CPHA
Enable SPI
SPEN = 1
Get Status
Read SPSTA
Prepare New Transfer
Write Data in SPDAT
Get Data Received
Read SPDAT
Prepare Transfer
Write Data in SPDAT
76543210
SPR2 SPEN SSDIS MSTR CPOL CPHA SPR1 SPR0
Bit
Number
Bit
Mnemonic Description
7SPR2
SPI Rate Bit 2
Refer to Table 97 for bit rate description.
6SPEN
SPI Enable Bit
Set to enable the SPI interface.
Clear to disable the SPI interface.
5SSDIS
Slave Select Input Disable Bit
Set to disable SS
in both master and slave modes. In slave mode this bit has no
effect if CPHA = 0.
Clear to enable SS
in both master and slave modes.
4MSTR
Master Mode Select
Set to select the master mode.
Clear to select the slave mode.