
V PeRiPheRaL MoDuLes 3 (inteRFaCe): seRiaL PeRiPheRaL inteRFaCe (sPi)
V-3-4
ePson
s1C33L17 teChniCaL ManuaL
V.3.4 setting sPi Module
When performing data transfers via the SPI bus, the following settings must be made before data transfer is actually
begun:
1. Setting input/output pins
2. Selecting master or slave mode
3. Setting the data bit width
4. Setting the bit rate
5. Setting the SPI_CLK polarity and phase
6. Setting the inter-character wait cycle
7. Setting the receive data mask
8. Setting interrupts and IDMA/HSDMA
The following explains the content of each setting. For details on interrupt/DMA settings, refer to Section V.3.6, “SPI
Interrupts and DMA.”
note: Always make sure the SPI module is inactive (ENA (D0/0x301708) = 0) before these settings are
made. A change of settings during operation may cause a malfunction.
ena: SPI Enable Bit in the SPI Control Register 1 (D0/0x301708)
setting input/output pins
The SDI, SDO, and SPI_CLK pins are used for SPI. Configure the Port Function Select Registers to enable
these pin functions. For details of pin functions and how to switch over, see Section I.3.3, “Switching Over the
Multiplexed Pin Functions.”
selecting master or slave mode
Use MODE (D1/0x301708) to select whether the SPI module is set to master mode or slave mode. Setting
MODE (D1/0x301708) to 1 selects master mode, and setting to 0 (default) selects slave mode. In master mode,
the SPI performs data transfer using the clock generated in the module. In slave mode, the SPI performs data
transfer using a clock input from the master device.
MoDe: SPI Mode Select Bit in the SPI Control Register 1 (D1/0x301708)
setting the data bit width
Use BPT[4:0] (D[14:10]/0x301708) to set the data bit width of the transfer data (characters). Data bit width is
set as the BPT[4:0] (D[14:10]/0x301708) set value + 1 (for example, 16 bits when BPT[4:0] = 15).
BPt[4:0]: Number of Data Bits Per Transfer Setup Bits in the SPI Control Register 1 (D[14:10]/0x301708)
setting the bit rate
When the SPI module is set in master mode, the synchronous clock is generated inside the module. The syn-
chronous clock drives the shift register and is output from the SPI_CLK pin to slave devices. Specify the clock
frequency using MCBR[2:0] (D[6:4]/0x301708) to determine he bit rate.
MCBR[2:0]: Master Clock Bit Rate Setup Bits in the SPI Control Register 1 (D[6:4]/0x301708)
Table V.3.4.1 Setting the Clock Frequency
MCBR2
1
0
MCBR1
1
0
1
0
MCBR0
1
0
1
0
1
0
1
0
Clock frequency (hz)
MCLK/256
MCLK/128
MCLK/64
MCLK/32
MCLK/16
MCLK/8
MCLK/4
MCLK/2
Slave mode does not need to set a bit rate as the SPI module operates with the clock input from the master de-
vice.