
V PERIPHERAL MODULES 3 (INTERFACE): SERIAL PERIPHERAL INTERFACE (SPI)
V-2-6
EPSON
S1C33E07 TECHNICAL MANUAL
V.2.5 Control of Data Transfer
Data transmission
The following shows the data-transmit 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.
ENA: SPI Enable Bit in the SPI Control Register 1 (D0/0x301708)
4. In slave mode, write 1 to SS (D10/0x30170C) to set this slave SPI into selected status. This enables clock
input from the SPI_CLK pin.
SS: Slave Select Control Bit in the SPI Control Register 2 (D10/0x30170C)
In master mode, SS (D10/0x30170C) must be set to 0.
5. Write the transmit data to the SPI Transmit Data Register (0x301704).
The SPI circuit loads the data written to the register into the shift register. In master mode, the SPI circuit
starts outputting the clock from the SPI_CLK pin. In slave mode, the SPI circuit waits for clock input from
the SPI_CLK pin. The data bits in the shift register are shifted one by one at the rising or falling edge con-
figured with CPHA (D9/0x301708) and CPOL (D8/0x301708) (see Figure V.2.4.1), and are output from the
SDO pin. The MSB of data is transmitted first.
CPHA: SPI_CLK Phase Select Bit in the SPI Control Register 1 (D9/0x301708)
CPOL: SPI_CLK Polarity Select Bit in the SPI Control Register 1 (D8/0x301708)
The SPI circuit provides TDEF (D4/0x301714) to indicate the SPI Transmit Data Register (0x301704) sta-
tus. This flag is reset to 0 (not empty) when data is written to the transmit data register and is set to 1 (empty)
when the written data is loaded into the shift register. An interrupt can be generated simultaneous with this
flag set to 1. Check to see if the TDEF (D4/0x301714) is set to 1 by polling or using this interrupt before
the next transmit data can be written to the SPI Transmit Data Register (0x301704).
TDEF: Transmit Data Empty Flag in the SPI Status Register (D4/0x301714)
Furthermore, by setting TXDE (D3/0x301708) to 1, a transmit DMA request is output to the ITC. This
DMA request can be used to set transmit data without using the interrupt above.
TXDE: Transmit DMA Enable Bit in the SPI Control Register 1 (D3/0x301708)
The SPI circuit continues data output from the SDO pin and clock input/output from/to the SPI_CLK pin
until data transmission for the number of bits specified with the BPT[4:0] (D[14:10]/0x301708) is finished.
If the next transmit data exists in the SPI Transmit Data Register (0x301704) when a data transfer has fin-
ished in master mode, the SPI circuit repeats the same transmit operation as above. However, the SPI circuit
delays starting the next transmission for the number of SPI_CLK cycles specified with the SPI Wait Regis-
ter (0x301710). The data written to the transmit data register is not loaded into the shift register until after
the expiration of the delay time.
When a continuous data transmission is being performed in slave mode, the SPI Wait Register (0x301710)
does not affect the transmission (no delay is inserted) as the clock is controlled by the master device. The
next transmit data must be written to the SPI Transmit Data Register (0x301704) before the master starts
sending the next data transfer clocks.
In master mode, the transmitter status sets/resets BSYF (D6/0x301714). BSYF (D6/0x301714) is set to 1
when transmission is in progress or in the wait cycles specified with the SPI Wait Register (0x301710), and
reset to 0 upon completion of a transmit operation. Use this flag to check if a transmission has completed.
This flag is ineffective in slave mode (always 0 is read).
BSYF: Transfer Busy Flag in the SPI Status Register (D6/0x301714)