STM32H7 - MDMA with DCMI

I am using DCMI peripheral on STM32H7 to capture an 320x240 monochrome image (1 byte per pixel) and DMA to transfer it to D1 SRAM. DMA uses FIFO, Threshold: Full, Data width: Word for both source and destination.

I would like to make a copy of that image array so I can analyse it while the original array is filling in with a new frame. I have done this using another DMA Memory-to-memory and it works great.

The problem is I have to manually start the DMA Mem-to-mem transfer. So I was thinking of using MDMA which can be hardware triggered by DCMI's DMA.

I have spent whole day of trying to get MDMA working in that way, but I always get unsatisfactory results, i.e. sometime only cca. 50 image rows of 240 total are copied to the new array and sometimes none are copied. I tried to configure MDMA using CubeMX and change settings like:

Triger mode: Buffer transfer, block transfer, Repeat block transfer and Full transfer.

List type: Linear, Circular and Buffer Length.

I also tried changing arguments BlockDataLength and BlockCount when calling:

HAL_MDMA_Start (&hmdma, (uint32_t)&SrcAddress, (uint32_t)&DstAddress, BlockDataLength, BlockCount);


But I never seems to be able to copy the whole aray (76800B). I have read AN for MDMA but still some things are foggy. Could somebody help me on how to configure the MDMA settings for this case? The DCMI's DMA uses a 4 word FIFO.

• Have you considered using regular DMA in double buffer mode? Then no additional mem-to-mem transfer would be needed. DMA would switch over to a second buffer when the first one is filled. – berendi Jun 17 at 6:25