cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 Mem-to-Mem DMA problems

mwp
Senior
Posted on June 09, 2016 at 20:36

Hi all,

I'm trying to setup a very simple Memory to Memory DMA transfer. DMA status registers report that the transfer completes OK, but the memory contents is not transferred. Can anyone see why the code below doesn't work? Ret is always HAL_OK. The contents of var C is never copied into var D. Thanks in advance!

{
__HAL_RCC_DMA2_CLK_ENABLE();
/* Configure DMA request hdma_memtomem_dma2_stream0 on DMA2_Stream0 */
hdma_memtomem_dma2_stream0.Instance = DMA2_Stream0;
hdma_memtomem_dma2_stream0.Init.Channel = DMA_CHANNEL_0;
hdma_memtomem_dma2_stream0.Init.Direction = DMA_MEMORY_TO_MEMORY;
hdma_memtomem_dma2_stream0.Init.PeriphInc = DMA_PINC_ENABLE;
hdma_memtomem_dma2_stream0.Init.MemInc = DMA_MINC_ENABLE;
hdma_memtomem_dma2_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_memtomem_dma2_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_memtomem_dma2_stream0.Init.Mode = DMA_NORMAL;
hdma_memtomem_dma2_stream0.Init.Priority = DMA_PRIORITY_MEDIUM;
hdma_memtomem_dma2_stream0.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_memtomem_dma2_stream0.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_memtomem_dma2_stream0.Init.MemBurst = DMA_MBURST_SINGLE;
hdma_memtomem_dma2_stream0.Init.PeriphBurst = DMA_PBURST_SINGLE;
if
(HAL_DMA_Init(&hdma_memtomem_dma2_stream0) != HAL_OK)
{
Error_Handler();
}
HAL_StatusTypeDef ret;
volatile uint32_t __attribute__ ((aligned (64))) c[0xff];
volatile uint32_t __attribute__ ((aligned (64))) d[0xff];
#define SRCMEM ((uint32_t)&c[0])
#define DESTMEM ((uint32_t)&d[0])
while
(1)
{
memset(c, 0xff, 
sizeof
(c));
memset(d, 0x11, 
sizeof
(d));
ret = HAL_DMA_Start(&hdma_memtomem_dma2_stream0, SRCMEM, DESTMEM, 16);
ret = HAL_DMA_PollForTransfer(&hdma_memtomem_dma2_stream0, HAL_DMA_FULL_TRANSFER, 10000);
HAL_Delay(1); 
//break here and check result
}
}

#stm32f7 #dma
3 REPLIES 3
Posted on June 09, 2016 at 21:01

Data stuck in cache?

JW
Walid FTITI_O
Senior II
Posted on June 10, 2016 at 11:45

Hi MWP,

I suggest that you check and run the ''DMA_FIFOMode'' example in

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef7.html

to compare the code there with yours and identify what you missed.

the example at this path: STM32Cube_FW_F7_V1.4.0\Projects\STM32756G_EVAL\Examples\DMA\DMA_FIFOMode

-Hannibal-

mwp
Senior
Posted on June 12, 2016 at 19:58

Data cache was the issue, thank you!