11 SYNCHRONOUS SERIAL INTERFACE (SPI)
S1C17F13 TeChniCal Manual
Seiko epson Corporation
11-7
(Rev. 1.0)
Data Reception in Master Mode
11.5.3
A data receiving procedure and operations in master mode are shown below. Figures 11.5.3.1 and 11.5.3.2 show a
timing chart and flowcharts, respectively.
Data receiving procedure
1. Assert the slave select signal by controlling the general-purpose output port (if necessary).
2. Check to see if the SPI
n
INTF.TBEIF bit is set to 1 (transmit buffer empty).
3. Write dummy data (or transmit data) to the SPI
n
TXD register.
4. Wait for a transmit buffer empty interrupt (SPI
n
INTF.TBEIF bit = 1).
5. Write dummy data (or transmit data) to the SPI
n
TXD register.
6. Wait for a receive buffer full interrupt (SPI
n
INTF.RBFIF bit = 1).
7. Read the received data from the SPI
n
RXD register.
8. Repeat Steps 5 to 7 until the end of data reception.
9. Negate the slave select signal by controlling the general-purpose output port (if necessary).
Note: To perform continuous data reception without stopping SPICLK
n
, Steps 7 and 5 operations must
be completed within seven SPICLK
n
cycles after Step 6.
Data receiving operations
The SPI Ch.
n
starts data receiving operations simultaneously with data sending operations when transmit data
(may be dummy data if data transmission is not required) is written to the SPI
n
TXD register.
The SPICLK
n
pin outputs eight clocks. The transmit data bits are output in sequence from the SDO
n
pin in
sync with this clock and the receive data bits input from the SDI
n
pin are shifted into the shift register.
When the eighth clock is output from the SPICLK
n
pin and 8-bit receive data is shifted into the shift register,
the received data is transferred to the receive data buffer and the SPI
n
INTF.RBFIF bit is set to 1. At the same
time the SPI issues a receive buffer full interrupt request if the SPI
n
INTE.RBFIE bit = 1. After that, the re-
ceived data in the receive data buffer can be read through the SPI
n
RXD register.
Note: 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.
SPICLK
n
SDO
n
SDI
n
SPI
n
INTF.TBEIF
SPI
n
INTF.RBFIF
SPI
n
INTF.TENDIF
Software operations
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)
1 (W)
→
SPI
n
INTF.TENDIF
SPI
n
RXD
→
Data (R)
SPI
n
RXD
→
Data (R)
5.3.1 Example of Data Receiving Operations in Master Mode
Figure 11.