GD32F403xx User Manual
173
base address registers (DMA_CHxPADDR, DMA_CHxMADDR).
In the increasing mode, the next address is equal to the current address plus 1 or 2 or 4,
depending on the transfer data width.
10.4.5.
Circular mode
Circular mode is implemented to handle continue peripheral requests (for example, ADC scan
mode). The circular mode is enabled by setting the CMEN bit in the DMA_CHxCTL register.
In circular mode, the CNT bits are automatically reloaded with the pre-programmed value and
the f ull transf er f inish f lag is asserted at the end of every DMA transf er. DMA can always
responds the peripheral request until the CHEN bit in the DMA_CHxCTL register is cleared.
10.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 f rom 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.
10.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.
Conf igure the M2M bit and DIR bit in the DMA_CHxCTL register to set the transfer mode.
3.
Conf igure the CMEN bit in the DMA_CHxCTL register to enable/disable the circular
mode.
4.
Conf igure the PRIO bits in the DMA_CHxCTL register to set the channel software priority.
5.
Conf igure the memory and peripheral transf er width, memory and peripheral address
generation algorithm in the DMA_CHxCTL register.
6.
Conf igure the enable bit f or f ull transfer f inish interrupt, half transfer f inish interrupt,
transf er error interrupt in the DMA_CHxCTL register.
7.
Conf igure the DMA_CHxPADDR register for setting the peripheral base address.
8.
Conf igure the DMA_CHxMADDR register for setting the memory base address.
9.
Conf igure the DMA_CHxCNT register to set the total transfer data number.
10. Conf igure the CHEN bit
with ‘1’ in the DMA_CHxCTL register to enable the channel.
10.4.8.
Interrupt
Each DMA channel has a dedicated interrupt. There are three types of interrupt event,