
RM0008
Serial peripheral interface (SPI)
Doc ID 13902 Rev 12
695/1096
Figure 247. Reception using DMA
DMA capability with CRC
When SPI communication is enabled with CRC communication and DMA mode,the
transmission and reception of the CRC at the end of communication are automatic i.e.
without using the bit CRCNEXT. After the CRC reception, the CRC must be read in the
SPI_DR register in order to clear the RXNE flag.
At the end of data and CRC transfers, the CRCERR flag in SPI_SR is set if corruption
occurs during the transfer.
25.3.10 Error
flags
Master mode fault (MODF)
Master mode fault occurs when the master device has its NSS pin pulled low (in NSS
hardware mode) or SSI bit low (in NSS software mode), this automatically sets the MODF
bit. Master mode fault affects the SPI peripheral in the following ways:
●
The MODF bit is set and an SPI interrupt is generated if the ERRIE bit is set.
●
The SPE bit is cleared. This blocks all output from the device and disables the SPI
interface.
●
The MSTR bit is cleared, thus forcing the device into slave mode.
Use the following software sequence to clear the MODF bit:
1.
Make a read or write access to the SPI_SR register while the MODF bit is set.
2.
Then write to the SPI_CR1 register.
To avoid any multiple slave conflicts in a system comprising several MCUs, the NSS pin
must be pulled high during the MODF bit clearing sequence. The SPE and MSTR bits can
be restored to their original state after this clearing sequence.
MI
S
O/MO
S
I (in)
DATA 1 = 0xA1
software configures the
DMA SPI Rx channel
to receive 3 data items
and enables the SPI
S
CK
DATA 2 = 0xA2
DATA
3
= 0xA
3
Ex
a
mple with CPOL=1, CPHA=1
RXNE fl
a
g
Rx
bu
ffer
s
et
b
y h
a
rdw
a
re
(re
a
d from
S
PI_DR)
0xA1
0xA2
0xA
3
DMA re
qu
e
s
t
DMA reads
DATA3 from
SPI_DR
fl
a
g DMA TCIF
s
et
b
y h
a
rdw
a
re
cle
a
r
b
y
s
oftw
a
re
DMA re
a
d from
S
PI_DR
The DMA transfer is
complete (TCIF=1 in
DMA_ISR)
DMA reads
DATA2 from
SPI_DR
DMA reads
DATA1 from
SPI_DR
(DMA tr
a
n
s
fer complete)
b
0
b
1
b
2
b3 b
4
b
5
b
6
b
7
b
0
b
1
b
2
b3 b
4
b
5
b
6
b
7
b
0
b
1
b
2
b3 b
4
b
5
b
6
b
7
cle
a
r
b
y DMA re
a
d
a
i17
3
50