
AT32F413
Series Reference Manual
2022.06.27
Page 174
Rev 2.00
13.3.5 DMA transfer
The SPI interface supports data write and read using DMA. Whether as SPI or I
2
S, read/write request
using DMA comes from the same peripheral. As a result, their configuration procedure are the same,
described as follows.
Transmission with DMA
Select a DMA channel: Select a DMA channel for the current SPI from DMA channel map table
described in DMA chapter.
Configure the destination of DMA transfer: Configure the SPI_DT register address as the
destination address bit of DMA transfer in the DMA control register. Datat will be sent to this
address after transmit request is received by DMA.
Configure the source of DMA transfer: Configure the memory address as the source of DMA
transfer in the DMA control register. Data will be loaded into the SPI_DT register from the
memory address after transmit request is received by DMA.
Configure the total number of bytes to be transferred in the DMA control register.
Configure the channel priority of DMA transfer in the DMA control register.
Configure DMA interrupt generation after half or full transfer in the DMA control register.
Enable DMA transfer channel in the DMA control register.
Reception with DMA
Select a DMA transfer channel: Select a DMA channel for the current SPI from DMA channel
map table described in DMA chapter.
Configure the destination of DMA transfer: Configure the memory address as the destination of
DMA transfer in the DMA control register. Data will be loaded from the SPI_DT register to the
programmed destination after reception request is received by DMA.
Configure the source of DMA transfer: Configure the SPI_DT register address as the source of
DMA transfer in the DMA control register. Data will be loaded from the SPI_DT register to the
programmed destination after reception request is received by DMA.
Configure the total number of bytes to be transferred in the DMA control register.
Configure the total number of bytes to be transferred in the DMA control register.
Configure DMA interrupt generation after half or full transfer in the DMA control registe
Enable DMA transfer channel in the DMA control register.
13.3.6 Transmitter/Receiver
Whether used as SPI or I2S, there is no difference for CPU. The SPI (in whatever mode) shares the
same base address, the same SPI_DT register, the same transmitter and receiver. The SPI transmitter
and receiver is responsible for sending and receiving the desired data frame according to the
configuration of the communication controller. Thus their status flags such as TDBE, RDBF and ROERR,
and their interrupt enable bits including TDBEIE, RDBFIE and ERRIE are identifical.
Special attention must be paid to:
CRC check is not supported on the I
2
S. Any operation relative to CRC, including CCERR flag
and the corresponding interrupts, is not supported.
I
2
S protocol needs decode the current channel status. The ACS bit is used to judge whether the
current transfer occurs on the left channel (ACS=0) or the right channel (ACS=1).
TUERR bit indicates whether an underrun occurs. TUERR=1 means an underrun error occurs on
the transmitter. An interrupt is generated when the ERRIE is set.
Read/write operation to the SPI_DT register is different under different audio protocols, data bits
and channel bits. Refer to the audio protocol selector section for more information.
Pay more attention to the I
2
S disable operation under different configurations, shown as follows:
−
2SDBN=00, I2SCBN=1, STDSLE=10: wait for the second-to-last RDBF=1 and 17 CK
periods before disabling the I
2
S.