AT32F425
Series Reference Manual
2022.03.30
Page 139
Ver 2.01
11.4.8 Data transfer using DMA
I
2
C data transfer can be done using DMA controller so as to reduce the burden on the CPU. The TDIEN
and RDIEN must be set 0 when using DMA for data transfer.
Transmission using DMA (DMATEN=1)
1.
Set the peripheral address (DMA_CxPADDR=
I2C_TXD
T address)
2.
Set the memory address (DMA_CxMADDR=data memory address)
3.
The transmission direction is set from memory to peripheral (DTD=1 in the DMA_CHCTRL
register)
4.
Configure the total number of bytes to be transferred in the DMA_CxDTCNT register
5.
Configure other parameters such as priority, memory data width, peripheral data width,
interrupts, etc in the DMA_CHCTRL register
6.
Enable the DMA channel by setting CHEN=1 in the DMA_CxCTRL register
7.
Enable I
2
C
DMA request by setting DMAEN=1 in the
I2C_CTRL2 register. Once the TDBE
bit in the
I2C_STS1 register is set, the data is loaded from the programmed memory to the
I2C_DT register through DMA
8.
When the number of data transfers, programmed in the DMA controller, is reached
(DMA_CxDTCNT=0), the data transfer is complete (An interrupt is generated if enabled).
9.
Master transmitter: Once the TDC flag is set, the STOP condition is generated, indicating that
transfer is complete.
Slave transmitter: Once the ACKFAIL flag is set, clear the ACKFAIL flag, transfer is complete.
Reception using DMA (DMAREN=1)
1.
Set the peripheral address (DMA_CxPADDR =
I2C_RXDT address
)
2.
Set the memory address (DMA_CxMADDR = memory address)
3.
The transmission directionis set from peripheral to memory (DTD=0 in the DMA_CHCTRL
register)
4.
Configure the total number of bytes to be transferred in the DMA_CxDTCNT register
5.
Configure other parameters such as priority, memory data width, peripheral data width,
interrupts, etc in the DMA_CHCTRL register
6.
Enable the DMA channel by setting CHEN=1 in the DMA_CxCTRL register
7.
Enable
I
2
C
DMA request by setting DMAEN=1 in the
I2C_CTRL2 register. Once the RDBE
bit in the
I2C_STS1 register is set, the data is loaded from the
I2C_DT register
to the
programmed memory
through DMA
8.
When the number of data transfers, programmed in the DMA controller, is reached
(DMA_CxDTCNT=0), the data transfer is complete (An interrupt is generated if enabled).
9.
Master receiver: Clear the ACKFAIL flag, the STOP condition is generated, indicating that the
transfer is complete (when the number of bytes to be transferred is greater >=2 and
DMAEND=1, the NACK signal is generated automatically after transfer complete
(DMA_CxDTCNT=0))
Slave receiver: Once the STOPF flag is set, clear the STOPF flag, and the transfer is complete.
11.4.9 Error management
The error management feature included in the I
2
C provides a guarantee for the reliability of
presents the manageable error events:
Table 11-6 I
2
C error events
Error event
Event Flag
Enable control bit
Clear bit
SMBus alert
ALERTF
ERRIEN
ALERTC
Timeout error
TMOUT
ERRIEN
TMOUTC
PEC error
PECERR
ERRIEN
PECERRC