How to implement double buffer STM32U575 GPDMA
Hiya. I’ve been trying to implement a double buffer with the GPDMA for a week now. I’m trying to capture an image using DCMI. I can get it to work with a single buffer, but I have not been able to get it to work with two LL nodes and two buffers.
I want the GPDMA to go between bufferA and bufferB, so I can process the alternate node i.e., if the DMA is loading into buffer B, then I process A. A simple ping-pong.
I’m not sure how I’m supposed to alter my current approach with a single buffer to two.
This is what I have for my linked list setup in MX_DCMIQueue_Config.
...
pNodeConfig.SrcAddress = 0;
pNodeConfig.DstAddress = (uint32_t)bufferA;
pNodeConfig.DataSize = DB_SIZE_WORDS;
/* Build DCMI_Node1 Node */
ret |= HAL_DMAEx_List_BuildNode(&pNodeConfig, &DCMI_Node1);
/* Insert DCMI_Node1 to Queue */
ret |= HAL_DMAEx_List_InsertNode_Tail(&DCMIQueue, &DCMI_Node1);
/* Set node configuration ################################################*/
pNodeConfig.DstAddress = (uint32_t)bufferB;
/* Build DCMI_Node2 Node */
ret |= HAL_DMAEx_List_BuildNode(&pNodeConfig, &DCMI_Node2);
/* Insert DCMI_Node2 to Queue */
ret |= HAL_DMAEx_List_InsertNode_Tail(&DCMIQueue, &DCMI_Node2);
ret |= HAL_DMAEx_List_SetCircularModeConfig(&DCMIQueue, &DCMI_Node1);
return ret;
}Before with the single buffer, I was starting the GPDMA with:
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS, (uint32_t)pBuffer, MAX_PICTURE_BUFF);But I haven’t been able to get it to work, by swapping out the buffer with the first buffer “bufferA” and the datasize as the buffer size.
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS, (uint32_t)bufferA, DB_SIZE_WORDS);
Is there extra code I need to do to configure the GPDMA to write between two different buffers and circulate? Only the first buffer seems to be populating. The DMA should go A → B → A → B→…, overwriting the data in the process when it changes nodes.
Any help would be greatly appreciated.
