2016-06-09 11:36 AM
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
2016-06-09 12:01 PM
Data stuck in cache?
JW2016-06-10 02:45 AM
Hi MWP,
I suggest that you check and run the ''DMA_FIFOMode'' example in 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-2016-06-12 10:58 AM
Data cache was the issue, thank you!