GR740-UM-DS, Nov 2017, Version 1.7
328
www.cobham.com/gaisler
GR740
24
SPI Controller supporting master and slave operation
24.1
Overview
The core provides a link between the AMBA APB bus and the Serial Peripheral Interface (SPI) bus
and can be dynamically configured to function either as a SPI master or a slave. The SPI bus parame-
ters are highly configurable via registers. Core features also include configurable word length, bit
ordering, clock gap insertion and automatic slave select. All SPI modes are supported and also a 3-
wire mode where one bidirectional data line is used. In slave mode the core synchronizes the incom-
ing clock and can operate in systems where other SPI devices are driven by asynchronous clocks.
24.2
Operation
24.2.1 SPI transmission protocol
The SPI bus is a full-duplex synchronous serial bus. Transmission starts when a master selects a slave
through the slave’s Slave Select (SPI_SLVSEL) signal and the clock line SCK transitions from its idle
state. Data is transferred from the master through the Master-Output-Slave-Input (SPI_MOSI) signal
and from the slave through the Master-Input-Slave-Output (SPI_MISO) signal. In a system with only
one master and one slave, the Slave Select input of the slave may be always active and the master does
not need to have a slave select output. If the core is configured as a master it will monitor the SPISEL
signal to detect collisions with other masters, if SPI_SEL is activated the master will be disabled.
During a transmission on the SPI bus data is either changed or read at a transition of SPI_SCK. If data
has been read at edge n, data is changed at edge n+1. If data is read at the first transition of SPI_SCK
the bus is said to have clock phase 0, and if data is changed at the first transition of SCK the bus has
clock phase 1. The idle state of SPI_SCK may be either high or low. If the idle state of SPI_SCK is
low, the bus has clock polarity 0 and if the idle state is high the clock polarity is 1. The combined val-
ues of clock polarity (CPOL) and clock phase (CPHA) determine the mode of the SPI bus. Figure 42
shows one byte (0x55) being transferred MSb first over the SPI bus under the four different modes.
Note that the idle state of the MOSI line is ‘1’ and that CPHA = 0 means that the devices must have
data ready before the first transition of SPI_SCK. The figure does not include the SPI_MISO signal,
the behavior of this line is the same as for the SPI_MOSI signal. However, due to synchronization
issues the SPI_MISO signal will be delayed when the core is operating in slave mode, please see sec-
tion 24.2.5 for details.
Figure 41.
Block diagram
A
M
B
A
A
P
B
Transmit
SPI_MISO
Mode register
Event register
Mask register
Com. register
Transmit register
Receive register
Slave select reg.
FIFO
Receive
FIFO
SPI_SCK
Control
Master ctrl
Slave ctrl
Clock gen.
S
y
n
c
r
e
g
i
s
t
e
r
s
SPI_SEL
SPI_SLVSEL[1:0]
SPI_MOSI
SPICTRL