R01UH0823EJ0100 Rev.1.00
Page 1394 of 1823
Jul 31, 2019
RX23W Group
38. Serial Peripheral Interface (RSPIa)
(9) Software Processing Flow
show examples of the flow of software processing.
(a) Transmit Processing Flow
When transmitting data, the CPU will be notified of the completion of data transmission by enabling the SPI interrupt
after the last writing of data for transmission.
The completion of data transmission can also be checked by polling to see if the SPSR.IDLNF flag has become 0, instead
of using the SPII interrupt. However, one cycle of PCLK is required for the time from when data for transmission is
written in the SPDR register to when the IDLNF flag becomes 1. After the last data is written in the SPDR register,
discard the value of the SPSR register once not to judge the condition with the IDLNF flag which has not yet become 1,
and read and use the value of the SPSR.IDLNF flag to confirm the completion of data transmission.
Figure 38.36
Flowchart in Master Mode (Transmission)
[4] Each time the handling routine
runs, access to the number of
frames set in the
SPDCR.SPFC[1:0] bits proceeds.
Processing for transmission
Start processing
for transmission
SPTI interrupt generated
or SPSR.SPTEF = 1?*
1
Yes
No
Have the last of the data been
written?
Yes
No
SPCR.SPTIE = 0,
SPCR2.SPIIE = 1
SPII interrupt?
Yes
No
SPCR.SPE = 0,
SPCR2.SPIIE = 0
End of
processing for
transmission
Set SPCR.SPE = 1 and set bits
SPTIE, SPRIE, and SPEIE
Proceed to
processing for
transmission
Proceed to
processing for
reception
Proceed to
error
processing
[3] Set the SPE bit to “enabled”.
Enable the required interrupts at the
same time (Disables the related
interrupt when using a polling).
Clear the SPSR.MODF, OVRF,
and PERF flags
End of initial settings
Pre-transfer processing
[1] Clear error sources.
Set SPCR2.SPIIE = 0
[2] Disable SPII interrupts.
[4]
Write data for transmission to
SPDR
Note 1.
When using a polling for the SPTEF flag, proceed to the transmit data writing process after reading the SPTEF flag as 1.