
CH32V003
Reference Manual
V1.3
63
(MEM2MEM=1), the channel is turned on (EN=1) to start data transfer. This mode does not support cyclic
mode.
The configuration process is as follows.
1)
Set the first address of the peripheral register or the memory data address in the memory-to-memory
mode (MEM2MEM=1) in the DMA_PADDRx register. This address will be the source or destination
address for data transfer when a DMA request occurs.
2)
Set the memory data address in the DMA_MADDRx register. When a DMA request occurs, the
transferred data will be read from or written to this address.
3)
Set the amount of data to be transferred in the DMA_CNTRx register. This value is decremented after
each data transfer.
4)
Set the priority of the channel in the PL[1:0] bits of the DMA_CFGRx register.
5)
Set the direction of data transfer, cyclic mode, incremental mode for peripheral and memory, data width
for peripheral and memory, transfer halfway, transfer complete, and transfer error interrupt enable bits in
the DMA_CFGRx register.
6)
Set the ENABLE bit of the DMA_CCRx register to start channel x.
Note: The DMA_PADDRx/DMA_MADDRx/DMA_CNTRx registers and the direction of data transfer (DIR),
cyclic mode (location), and incremental mode of peripherals and memory (MINC/PINC) control bits in the
DMA_CFGRx register can be configured to write only when the DMA channel is turned off.
3)
Circular mode
Setting CIRC position 1 of the DMA_CFGRx register enables the cyclic mode function for channel data
transfers. In cyclic mode, when the number of data transfers becomes 0, the contents of the DMA_CNTRx
register are automatically reloaded to its initial value, and the internal peripheral and memory address registers
are reloaded to the initial address values set by the DMA_PADDRx and DMA_MADDRx registers, and DMA
operation will continue until the channel is turned off or the DMA mode is turned off.
4)
DMA processing status
l
Transfer half: It corresponds to the hardware setting of HTIFx bit in DMA_INTFR register. The DMA
transfer half flag will be generated when the number of DMA transfers is reduced to less than half of the
initial set value, and an interrupt will be generated if HTIE is set in the DMA_CCRx register. The
hardware uses this flag to alert the application that it can prepare for a new round of data transfers.
l
Transfer completion: corresponds to the hardware setting of the TCIFx bit in the DMA_INTFR register.
When the number of DMA transfers decreases to 0, the DMA transfer completion flag will be generated,
and if TCIE is set in the DMA_CCRx register, an interrupt will be generated.
l
Transfer error: corresponds to a hardware set of the TEIFx bit in the DMA_INTFR register. Reading and
writing a reserved address area will generate a DMA transfer error. At the same time the module hardware
will automatically clear the EN bit of the DMA_CCRx register corresponding to the channel where the
error occurred, and the channel is turned off. If TEIE is set in the DMA_CCRx register, an interrupt will
be generated.
When the application queries the DMA channel status, it can first access the GIFx bit of the DMA_INTFR
register to determine which channel is currently experiencing a DMA event, and then process the specific
DAM event content for that channel.
8.2.2 Programmable total data transfer size/data bit width/alignment
The total size of the data to be transferred per DMA channel round is programmable up to 65535 times, and
the number of pending transfers is indicated in the DMA_CNTRx register. At EN=0, the set value is written,
and at EN=1 when the DMA transfer channel is turned on, this register becomes a read-only attribute with a
decreasing value after each transfer.
The transferred data fetch values of peripherals and memories support the address pointer auto-increment