STM32H5 DMA Overview

GPDMA

GPDMA 是一種系統週邊設備,是 AHB 匯流排上的雙埠主設備。 它被用於透過鍊錶在外部和/或記憶體之間傳輸資料。 所有 GPDMA 可程式傳輸均在系統層面提供更高效能,並使 CPU 無需執行這些資料傳輸任務。

STM32CubeMX建置

這邊和舊的DMA不同會全部都彙整到GPDMA處設定,在所需要開啟DMA的interface,設定會直接link到GPDMA設定這邊通常都設定標準模式

這邊注意不同通道會有不同字結長度

GPDMA Coding

這邊可以參考UART範例

#deifne RX_SIZE  (16)
#define TX_SIZE  (33)
  
ALIGN_32BYTES (uint8_t tx1_buffer[])="**STM32H5 UART Test with Polling**\r\n\n";
ALIGN_32BYTES (uint8_t tx_buffer[])="**STM32H5 UART Test with DMA**\r\n\n";
ALIGN_32BYTES (uint8_t rx_buffer[16]);
  
_HAL_LINKDMA(&huart3, hdmarx , handle_GPDMA1_Channel0);
_HAL_LINKDMA(&huart3, hdmatx, handle_GPDMA1_Channel1);%
   
   HAL_UART_Receive_DMA(&huart3,  rx_buffer,  RX_SIZE);//For RX
   
     /* USER CODE BEGIN WHILE */
while (1)
  {

    HAL_Delay(2023);

  HAL_UART_Transmit_DMA(&huart3, (uint8_t *)tx_buffer, TX_SIZE);
  //HAL_UART_Transmit(&huart3, (uint8_t *)tx1_buffer, 37,0xfff);
   huart3.gState = HAL_UART_STATE_READY
   
  }

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart