www
.mcu.com.cn
173
/
239
Rev.
1.00
CMS80F731x Reference Manual
20.6 SPI Slave Mode
When configured as an SPI slave device, SPI transmission is initiated by an external SPI host module by using the SPI
slave selection input and generates an SCLK serial clock.
Before the transfer begins, it is necessary to determine which SPI slave will be used to exchange data. The NSS is used
(clear = 0), and the clock signal connected to the SCLK line will transfer the SPI from the Slave device to the receiving shift
register contents of the MOSI line and drive the MISO line with the contents of the transmitter shift registers. When all 8 bits are
moved in/out, SPI generates an interrupt request by setting the IRQ output. The contents of the shift register drive the MISO
line.
In SPI slave mode, there can only be one transmit error - write conflict error.
20.6.1
Address Error
In slave mode, only write conflict errors can be detected by SPI.
When an SPDR register write operation is performed while an SPI transfer is in progress, a write violation error occurs.
In slave mode, when CPHA is cleared, a write collision error may occur as long as the NSS slave selection line is driven
low, even if all bits have been transmitted. This is because the transfer start is not explicitly specified, and the NSS is driven low
after a full-byte transfer may indicate the start of the next byte transfer.
20.6.2
Write Conflict Error
If the SPI data register is written during the transfer, a write violation occurs. The transfer continues uninterrupted, and the
write data that causes the error is not written to the shifter. Write conflicts are indicated by the WCOL flag in the SPSR register.
When a WCOL error occurs, the WCOL flag is automatically set to 1 by the hardware. To clear the WCOL bits, the user
should perform the following sequence:
-
Read the contents of the SPSR register;
-
Access the SPDR register (read or write).
The following figure shows a write violation error during transfer in SPI slave mode:
MISO
SCLK
WCOL
NSS
D6
D5
D4
D3
D2
D1
D0
D7
D6
D5
D4
D3
D2
D1
D0
SPIIF
D7