Hi,Do you have any DMA Memory-to-memory transfer examples? Ideally at register level, i.e. without the drivers library.
Please find attached an example source code for memory-to-memory DMA using the ADuCM302x, 'DMA-mem2mem.c'.
The example transfers 32 bytes of dummy data (26 letters from 'a' to 'z' and numbers '0' to '5') within SRAM, from location 0x20001000 to location 0x20001100 using the 'auto-request' mode of DMA.
//DATA to be transferred between two locations in SRAM.#define NUM_DATA 32static char nBufferSRC[NUM_DATA] @ 0x20001000 = "abcdefghijklmnopqrstuvwxyz012345" ;
uint8_t * dst_end = (uint8_t *)(0x20001100 + NUM_DATA - 1); uint8_t * src_end = (uint8_t *)(&nBufferSRC[NUM_DATA-1]);DmaCfg_AutoReq (20, (unsigned int*)src_end, (unsigned int *)dst_end, 0, 0, 0, 0, NUM_DATA);
uint8_t * dst_end = (uint8_t *)(0x20001100 + NUM_DATA - 1); uint8_t * src_end = (uint8_t *)(&nBufferSRC[NUM_DATA-1]);
DmaCfg_AutoReq (20, (unsigned int*)src_end, (unsigned int *)dst_end, 0, 0, 0, 0, NUM_DATA);
Channel #20 of the DMA controller is used for this memory to memory transfer (the eight channels between channel # 16 to #23 can be used for software triggered DMA). As you will observe in the example source code, the procedure is simple and comprises of setting up the source, destination end addresses and other parameters in the DMA descriptor followed by triggering of the memory to memory transfer using a software request corresponding to the selected channel.
In the attached example source code developed for the EV-COG-AD3029LZ, pressing BTN1 on the MCU Cog board triggers the DMA transaction after toggling LED1 on the board. A DMA Done IRQ handler is used in the example to toggle LED2, indicating completion of the memory to memory transfer.
The ADuCM302x is put in to the flexi power mode during the memory to memory DMA transfer, so that the core can be put in to sleep, thereby potentially saving on energy consumption.
Retrieving data ...