GD32F20x User Manual
235
12.4.6.
Memory to memory mode
The memory to memory mode is enabled by setting the M2M bit in the DMA_CHxCTL register.
In this mode, the DMA channel can also work without being triggered by a request from a
peripheral. The DMA channel starts transferring as soon as it is enabled by setting the CHEN
bit in the DMA_CHxCTL register, and completed when the DMA_CHxCNT register reaches
zero.
12.4.7.
Channel configuration
When starting a new DMA transfer, it is recommended to respect the following steps:
1.
Read the CHEN bit and judge whether the channel is enabled or not. If the channel is
enabled, clear the CHEN bit by software
. When the CHEN bit is read as ‘0’, configuring
and starting a new DMA transfer is allowed.
2.
Configure the M2M bit and DIR bit in the DMA_CHxCTL register to set the transfer mode.
3.
Configure the CMEN bit in the DMA_CHxCTL register to enable/disable the circular
mode.
4.
Configure the PRIO bits in the DMA_CHxCTL register to set the channel software priority.
5.
Configure the memory and peripheral transfer width, memory and peripheral address
generation algorithm in the DMA_CHxCTL register.
6.
Configure the enable bit for full transfer finish interrupt, half transfer finish interrupt,
transfer error interrupt in the DMA_CHxCTL register.
7.
Configure the DMA_CHxPADDR register for setting the peripheral base address.
8.
Configure the DMA_CHxMADDR register for setting the memory base address.
9.
Configure the DMA_CHxCNT register to set the total transfer data number.
10. Configure the DMA_ACFG register for setting the transfer mode for channel 5 of DMA1
if needed.
11. Configure the CHEN bit
with ‘1’ in the DMA_CHxCTL register to enable the channel.
12.4.8.
Interrupt
Each DMA channel has a dedicated interrupt. There are three types of interrupt event,
including full transfer finish, half transfer finish, and transfer error.
Each interrupt event has a dedicated flag bit in the DMA_INTF register, a dedicated clear bit
in the DMA_INTC register, and a dedicated enable bit in the DMA_CHxCTL register. The
relationship is described in the following
Table 12-3. Interrupt events
Interrupt event
Flag bit
Clear bit
Enable bit
DMA_INTF
DMA_INTC
DMA_CHxCTL
Full transfer finish
FTFIF
FTFIFC
FTFIE
Half transfer finish
HTFIF
HTFIFC
HTFIE
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...