I'm using SDK 2.16.100 and rt1062 MCU.
I encountered a problem when using DMA
I setup a tcd pool, and submit transfer with 2 or 3 configs to DMA channel 1, and when the edma callback is called , I found the TCD1 is all cleared to 0. When I only submit only one config, and after the edma callback is called, the TCD1 is remained.
Following is my code snippets:
Define global tcd pool
__attribute__((section(".bss.$SRAM_OC"))) edma_tcd_t __ALIGNED(4) g_tcd_pool[DMA_TCD_POOL_COUNT]; In my DMA setup Code:
EDMA_CreateHandle(&g_XY2_100_Feedback_EDMA_Handle, XY2_100_DMA, XY2_100_FEEDBACK_DMA_CH);
EDMA_SetCallback(&g_XY2_100_Feedback_EDMA_Handle, EDMA_Feedback_Callback, base);
EDMA_InstallTCDMemory(&g_XY2_100_Feedback_EDMA_Handle, g_tcd_pool, DMA_TCD_POOL_COUNT);Next, there is for-loop to setup transfer config
base->remaining_dma_buffer_count = TRANSFER_SIZE;
for (int i = 0; i < 2 && base->remaining_dma_buffer_count > 0; i ++) {
const uint32_t transfer_cnt = MIN(DMA_MAX_COUNT, base->remaining_dma_buffer_count);
const uint32_t offset = TRANSFER_SIZE - base->remaining_dma_buffer_count;
const uint32_t pointer = (uint32_t)(base->buffer_info.fb_pointer) + offset + (offset / DMA_MAX_COUNT);
EDMA_PrepareTransfer(&transfer_config,
(void *)shifter_buffer,
sizeof(xy2_100_feedback_data_t),
pointer, // plus 1 for memory address align assertion
sizeof(xy2_100_feedback_data_t),
sizeof(xy2_100_feedback_data_t),
transfer_cnt * sizeof(xy2_100_feedback_data_t),
kEDMA_PeripheralToMemory);
// transferConfig.srcOffset = sizeof(buf_info->pointer[0].x) + sizeof(buf_info->pointer[0].y);
base->remaining_dma_buffer_count -= transfer_cnt;
EDMA_SubmitTransfer(&g_XY2_100_Feedback_EDMA_Handle, &transfer_config);
}
EDMA_StartTransfer(&g_XY2_100_Feedback_EDMA_Handle);Break at EDMA_StartTransfer , got following memory values:
My Global TCD Pool
Then continue and break inside EDMA_HandleIRQ:
Now TCD1 is cleared
Then, sga in the following code will get zero:
uint32_t sga = (uint32_t)handle->base->TCD[handle->channel].DLAST_SGA;Thanks, I used the definition from example, it worked then.
Thanks.
I indeed used 32-byte boundary before, and now I changed back to it, the g_tcd_pool address is 0x20280f60, but the TCD1 is still 0 when the EDMA_HandleIRQ is called
( and also I called EDMA_ResetChannel)
Hi @sprhawk ,
Thank you so much for your interest in our products and for using our community..
Please check the following code.
1: Please refer to SDK Demo "evkbmimxrt1060_edma_scatter_gather"
__attribute__((section(".bss.$SRAM_OC"))) edma_tcd_t __ALIGNED(4) g_tcd_pool[DMA_TCD_POOL_COUNT];
2: I suggest you add function EDMA_ResetChannel, just as SDK demo do.
Please check above.
Wish it helps you.
If you still have question about it, please kindly let me know.
Wish you a nice day!
Best Regards
MayLiu