Serial peripheral interface (SPI)
27.3
SPI functional description
27.3.1
General description
The block diagram of the SPI is shown in
Figure 271. SPI block diagram
MOSI
MISO
SCK
NSS
Usually, the SPI is connected to external devices through 4 pins:
●
MISO: Master In / Slave Out data. This pin can be used to transmit data in slave mode
and receive data in master mode.
●
MOSI: Master Out / Slave In data. This pin can be used to transmit data in master
mode and receive data in slave mode.
●
SCK: Serial Clock output for SPI masters and input for SPI slaves.
●
NSS: Slave select. This is an optional pin to select a slave device. This pin acts as a
'chip select' to let the SPI master communicate with slaves individually and to avoid
contention on the data lines. Slave NSS inputs can be driven by standard IO ports on
the master device. The NSS pin may also be used as an output if enabled (SSOE bit)
and driven low if the SPI is in master configuration. In this manner, all NSS pins from
devices connected to the Master NSS pin see a low level and become slaves when
they are configured in NSS hardware mode. When configured in master mode with
NSS configured as an input (MSTR=1 and SSOE=0) and if NSS is pulled low, the SPI
797/1422
Address and data bus
Read
Rx buffer
Shift register
LSB first
Tx buffer
Write
Baud rate generator
Master control logic
Doc ID 018909 Rev 4
Figure
271.
SPI_CR2
TXE
RXNE
ERR
0
IE
IE
IE
SPI_SR
MOD
CRC
BSY
OVR
F
ERR
Communication
control
BR[2:0]
LSB
SPE BR2
BR1 BR0
FIRST
SPI_CR1
BIDI
CRC
CRC
BIDI
EN
Next
MODE
OE
RM0090
TXDM
RXDM
0
SSOE
AEN
AEN
TXE
RXNE
0
0
0
1
MSTR CPOL CPHA
RX
DFF
SSM SSI
ONLY
ai14744
Need help?
Do you have a question about the STM32F40 Series and is the answer not in the manual?
Questions and answers