GD32VF103 User Manual
137
the PRIO bits in the DMA_CHxCTL register.
–
For channels with equal software priority level, priority is given to the channel with lower
channel number.
9.4.4.
Address generation
Two kinds of address generation algorithm are implemented independently for memory and
peripheral, including the fixed mode and the increased mode. The PNAGA and MNAGA bit in
the DMA_CHxCTL register are used to configure the next address generation algorithm of
peripheral and memory.
In the fixed mode, the next address is always equal to the base address configured in the
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.
9.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 full transfer finish flag is asserted at the end of every DMA transfer. DMA can always
responds the peripheral request until the CHEN bit in the DMA_CHxCTL register is cleared.
9.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.
9.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.