11 SYNCHRONOUS SERIAL INTERFACE (SPI)
11-8
Seiko epson Corporation
S1C17F13 TeChniCal Manual
(Rev. 1.0)
Data reception
End
Read the SPI
n
INTF.TBEIF bit
Write dummy data (or transmit data) to
the SPI
n
TXD register
Read receive data from
the SPI
n
RXD register
YES
NO
NO
YES
Receive data remained?
SPI
n
INTF.TBEIF = 1 ?
Wait for an interrupt request
(SPI
n
INTF.RBFIF = 1)
(A) Intermittent data reception
Data reception
End
Read the SPI
n
INTF.TBEIF bit
Write dummy data (or transmit data) to
the SPI
n
TXD register
Read receive data from
the SPI
n
RXD register
YES
NO
NO
YES
Receive data remained?
SPI
n
INTF.TBEIF = 1 ?
Wait for an interrupt request
(SPI
n
INTF.TBEIF = 1)
(B) Continuous data reception
Write dummy data (or transmit data) to
the SPI
n
TXD register
Wait for an interrupt request
(SPI
n
INTF.RBFIF = 1)
Execute this sequence
within seven SPICLK
n
cycles from an interrupt
request
Negate the slave select signal output from
a general-purpose port
(
)
Negate the slave select signal output from
a general-purpose port
(
)
Assert the slave select signal output from
a general-purpose port
(
)
Assert the slave select signal output from
a general-purpose port
(
)
5.3.2 Data Reception Flowcharts in Master Mode
Figure 11.
Terminating Data Transfer in Master Mode
11.5.4
A procedure to terminate data transfer in master mode is shown below.
1. Wait for an end-of-transmission interrupt (SPI
n
INTF.TENDIF bit = 1).
2. Set the SPI
n
CTL.MODEN bit to 0 to disable the SPI Ch.
n
operations.
3. Stop the 16-bit timer to disable the clock supply to the SPI Ch.
n
.
Data Transfer in Slave Mode
11.5.5
A data sending/receiving procedure and operations in slave mode are shown below. Figures 11.5.5.1 and 11.5.5.2
show a timing chart and flowcharts, respectively.
Data sending procedure
1. Check to see if the SPI
n
INTF.TBEIF bit is set to 1 (transmit buffer empty).
2. Write transmit data to the SPI
n
TXD register.
3. Wait for a transmit buffer empty interrupt (SPI
n
INTF.TBEIF bit = 1).
4. Repeat Steps 2 and 3 until the end of transmit data.
Note: Transmit data must be written to the SPI
n
TXD register after the SPI
n
INTF.TBEIF bit is set to 1 un-
til the seventh SPICLK
n
clock is output. If no transmit data is written during this period, the data
bits input from the SDI
n
pin are shifted and output from the SDO
n
pin without being modified.
Data receiving procedure
1. Wait for a receive buffer full interrupt (SPI
n
INTF.RBFIF bit = 1).
2. Read the received data from the SPI
n
RXD register.
3. Repeat Steps 1 and 2 until the end of data reception.