Serial peripheral interface (SPI)
RM0090
888/1731
DocID018909 Rev 11
Figure 259. Transmission using DMA
Figure 260. Reception using DMA
0xF1
Tx b
u
ffer
TXE fl
a
g
0xF2
B
S
Y fl
a
g
0xF
3
s
et by h
a
rdw
a
re
cle
a
r by DMA write
s
et by h
a
rdw
a
re
cle
a
red by DMA write
s
et by h
a
rdw
a
re
s
et by h
a
rdw
a
re
S
CK
re
s
et
Ex
a
mple with CPOL=1, CPHA=1
(write to
S
PI_DR)
MI
S
O/MO
S
I (o
u
t)
DATA 1 = 0xF1
DATA 2 = 0xF2
DATA
3
= 0xF
3
software configures the
DMA SPI Tx channel
to send 3 data items
and enables the SPI
DMA write
s
to
S
PI_DR
DMA req
u
e
s
t
ignored by the DMA bec
aus
e
DMA TCIF fl
a
g
s
et by h
a
rdw
a
re
cle
a
r by
s
oftw
a
re
DMA writes
DATA1 into
SPI_DR
by h
a
rdw
a
re
DMA writes
DATA2 into
SPI_DR
DMA writes
DATA3 into
SPI_DR
software waits until BSY=0
(DMA tr
a
n
s
fer complete)
DMA transfer is
complete (TCIF=1 in
DMA_ISR)
software waits
until TXE=1
DMA tr
a
n
s
fer i
s
complete
b0 b1 b2 b
3
b4 b5 b6 b7 b0 b1 b2 b
3
b4 b5 b6 b7 b0 b1 b2 b
3
b4 b5 b6 b7
a
i17
3
49
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 b
u
ffer
s
et by h
a
rdw
a
re
(re
a
d from
S
PI_DR)
0xA1
0xA2
0xA
3
DMA req
u
e
s
t
DMA reads
DATA3 from
SPI_DR
fl
a
g DMA TCIF
s
et by h
a
rdw
a
re
cle
a
r
by
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)
b0 b1 b2 b
3
b4 b5 b6 b7 b0 b1 b2 b
3
b4 b5 b6 b7 b0 b1 b2 b
3
b4 b5 b6 b7
cle
a
r by DMA re
a
d
a
i17
3
50