
V PeRiPheRaL MoDuLes 3 (inteRFaCe): seRiaL PeRiPheRaL inteRFaCe (sPi)
s1C33L17 teChniCaL ManuaL
ePson
V-3-7
V
SPI
6. After all transmissions have completed, write 0 to ENA (D0/0x301708) to turn the SPI circuit off.
In slave mode, write 0 to SS (D10/0x30170C) to set this SPI slave to deselected status before writing 0 to
ENA (D0/0x301708).
MCLK
ENA
DIV_CLK (master mode)
SPITXD[31:0]
Shift register
SPI_CLK pin (CPHA = 1)
SPI_CLK pin (CPHA = 0)
Data output pin
BSYF
TDEF
Interrupt
AMSB
BMSB
AMSB-1
A0
Write
Transmit data empty
Wait cycles (master mode)
(SPIW +1)
× Tc(DIV_CLK)
Data A
Data B
Figure V.3.5.1 Data Transmit Timing Chart (CPOL = 0)
Data receiving
The following shows the data-receive procedure:
1. Set up the SPI conditions as described in the previous section.
2. Set up the interrupt and DMA conditions using the ITC registers and the SPI interrupt control register (ex-
plained later). When using the SPI interrupt, the cause of SPI interrupt flag in the ITC must be cleared be-
fore enabling the interrupt.
3. Write 1 to the ENA (D0/0x301708) to turn the SPI circuit on.
In master mode, the SPI circuit starts frequency division of the source clock.
4. In slave mode, write 1 to SS (D10/0x30170C) to set this slave SPI into selected state. This enables clock
input from the SPI_CLK pin.
In master mode, SS (D10/0x30170C) must be set to 0.
5. In master mode, write dummy data to the SPI Transmit Data Register (0x301704). Writing to the SPI Trans-
mit Data Register (0x301704) is used as the trigger for data receiving as well as start of data transmission.
Also actual data to be transmitted can be written as the SPI circuit performs data transmission and reception
simultaneously.
The SPI circuit starts output of the generated clock from the SPI_CLK pin.
In slave mode, the SPI circuit waits for clock input from the SPI_CLK pin. When performing data transmis-
sion and reception simultaneously, the transmit data should be written to the SPI Transmit Data Register
(0x301704) before a clock is input.
The data bits are fetched in the shift register one by one at the rising or falling edge configured with CPHA
(D9/0x301708) and CPOL (D8/0x301708) (see Figure V.3.4.1). The MSB of data is received first.
When the specified number of bit data is received in the shift register, the received data is loaded into the
SPI Receive Data Register (0x301700). The bit mask processing is performed in this loading stage. At the
same time, RDFF (D2/0x301714) is set to 1 (data full) to indicate that the receive data can be read from the
SPI Receive Data Register (0x301700) and a data receive interrupt can be generated.
RDFF: Receive Data Full Flag in the SPI Status Register (D2/0x301714)