How to use DMA memory to memory in stm32h723zgt6?

13 Views Asked by At

How to use DMA memory to memory in stm32H723zgt6, the following code doesn't work properly, how can I modify it?

My version of the HAL library is v1.9.0:

int dma1_sm1_test(dmaSMStruct *dmaSM)
{
    DMA_HandleTypeDef hdma_memtomem_dma1_stream7;
    
    uint8_t srcData[10] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x80};
    uint8_t dstData[10];
    uint16_t srcCrc = 0xA9B0;
    uint16_t crcRes = 0;
    
    /* DMA controller clock enable */
  __HAL_RCC_DMA1_CLK_ENABLE();

  /* Configure DMA request hdma_memtomem_dma1_stream7 on DMA1_Stream7 */
  hdma_memtomem_dma1_stream7.Instance = DMA1_Stream7;
  hdma_memtomem_dma1_stream7.Init.Request = DMA_REQUEST_MEM2MEM;
  hdma_memtomem_dma1_stream7.Init.Direction = DMA_MEMORY_TO_MEMORY;
  hdma_memtomem_dma1_stream7.Init.PeriphInc = DMA_PINC_ENABLE;
  hdma_memtomem_dma1_stream7.Init.MemInc = DMA_MINC_ENABLE;
  hdma_memtomem_dma1_stream7.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  hdma_memtomem_dma1_stream7.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
  hdma_memtomem_dma1_stream7.Init.Mode = DMA_NORMAL;
  hdma_memtomem_dma1_stream7.Init.Priority = DMA_PRIORITY_LOW;
  hdma_memtomem_dma1_stream7.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
  hdma_memtomem_dma1_stream7.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
  hdma_memtomem_dma1_stream7.Init.MemBurst = DMA_MBURST_SINGLE;
  hdma_memtomem_dma1_stream7.Init.PeriphBurst = DMA_PBURST_SINGLE;
    hdma_memtomem_dma1_stream7.XferCpltCallback = &DmaXfercompleteCallback;
  if (HAL_DMA_Init(&hdma_memtomem_dma1_stream7) != HAL_OK)
  {
    ;
  }
    
    HAL_DMA_Start(&hdma_memtomem_dma1_stream7, (uint32_t)srcData, (uint32_t)dstData, 10);
    
    while(!(__HAL_DMA_GET_FLAG(&hdma_memtomem_dma1_stream7, DMA_FLAG_TCIF3_7)))
    {
        ;
    }
    crcRes = crc16(dstData, 8);
    
    if(crcRes == srcCrc)
    {
        return 0;
    }
    else
    {
        return -1;
    }
}

I've debugged it with keil simulation, and I see that the DMA registers are configured, but it still doesn't transfer data.

0

There are 0 best solutions below