AnsweredAssumed Answered

STM32F7 Mem-to-Mem DMA problems

Question asked by MWP on Jun 9, 2016
Latest reply on Jun 12, 2016 by MWP
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!

    /* 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)
    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