Skip to main content
Associate III
July 31, 2026
Question

How to implement double buffer STM32U575 GPDMA

  • July 31, 2026
  • 5 replies
  • 86 views

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.

5 replies

Associate
July 31, 2026

I ran into something similar with GPDMA linked-list transfers. From your setup, the two nodes and circular mode look reasonable, so I’d double-check that the DCMI DMA is actually started using the linked-list configuration rather than the normal single-buffer setup. Also make sure the node block size matches the DCMI transfer size and check the DMA callbacks/status to confirm whether Node1 → Node2 is actually happening. If only bufferA fills, the DMA may still be running in the basic mode rather than traversing the linked list.

Associate III
July 31, 2026

Not sure what you mean by “may still be running in the basic mode”. Previously with the single buffer, I was running it in linked list mode and I was able to get it to work with 2 nodes pointing to the same single buffer. I’ve kept the initialisation process the same, so I’d doubt it’s not entering linked list mode.

With the double buffer, each buffer stores one row of pixels. Could the issue be related to the fact that previously the single buffer was the size of the entire image, but now it’s less so that’s where the error is coming from? I’m not sure though, just throwing ideas out there.

MM..1
Super User
July 31, 2026

Maybe better is use 2x size one buffer and simply half complete callback mark end of buff A part...

Associate III
July 31, 2026

I’ve tried this, I don’t think xferhalfcplt is supported with DCMI on this chip. I’ve tried looking for it but the function isn’t defined in the workspace, only on complete transfer :/

MM..1
Super User
July 31, 2026

Maybe HAL dont support it , but dma yes , try LL or manual setup.