11 SYNCHRONOUS SERIAL INTERFACE (SPI)
S1C17F13 TeChniCal Manual
Seiko epson Corporation
11-9
(Rev. 1.0)
Data transfer operations
The following shows the slave mode operations different from master mode:
• Slave mode operates with the SPI clock supplied from the external SPI master to the SPICLK
n
pin.
The data transfer rate is determined by the SPICLK
n
frequency. It is not necessary to control the 16-bit timer.
• The SPI can operate as a slave device only when the slave select signal input from the external SPI master to
the #SPISS
n
pin is set to the active (low) level.
If #SPISS
n
= high, the software transfer control, the SPICLK
n
pin input, and the SDI
n
pin input are all inef-
fective. If the #SPISS
n
signal goes high during data transfer, the transfer bit counter is cleared and data in the
shift register is discarded.
• Slave mode starts data transfer when SPICLK
n
is input from the external SPI master after the #SPISS
n
signal
is asserted. Writing transmit data is not a trigger to start data transfer. Therefore, it is not necessary to write
dummy data to the transmit data buffer when performing data reception only.
• Data transmission/reception can be performed even in SLEEP mode, it makes it possible to wake the CPU up
using an SPI interrupt.
Other operations are the same as master mode.
Notes:
•
If 8-bit data is received when the SPI
n
INTF.RBFIF bit is set to 1, the SPI
n
RXD register is over-
written with the newly received 8-bit data and the previously received data is lost. There is no
flag provided for indicating a loss of data.
•
When the clock for the first bit is input from the SPICLK
n
pin, the SPI starts sending the 8-bit
data currently stored in the shift register even if the SPI
n
INTF.TBEIF bit is set to 1.
#SPISS
n
SPICLK
n
SDO
n
SDI
n
SPI
n
INTF.TBEIF
SPI
n
INTF.RBFIF
Software operations
1 2 3
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Data (W)
→
SPI
n
TXD
Data (W)
→
SPI
n
TXD
Data (W)
→
SPI
n
TXD
SPI
n
RXD
→
Data (R)
SPI
n
RXD
→
Data (R)
5.5.1 Example of Data Transfer Operations in Slave Mode
Figure 11.
Data reception
End
Read receive data from
the SPI
n
RXD register
NO
YES
Receive data remained?
Wait for an interrupt request
(SPI
n
INTF.RBFIF = 1)
Data transmission
End
Read the SPI
n
INTF.TBEIF bit
Write transmit data to
the SPI
n
TXD register
YES
NO
NO
YES
Transmit data remained?
SPI
n
INTF.TBEIF = 1 ?
Wait for an interrupt request
(SPI
n
INTF.TBEIF = 1)
5.5.2 Data Transfer Flowcharts in Slave Mode
Figure 11.