Skip to main content
Visitor II
June 23, 2021
Solved

how to use UART with DMA

  • June 23, 2021
  • 5 replies
  • 8321 views

I am using STM32H7B0VBT6 MCU.

i want to transmit data using UART with DMA in normal mode.

i am using "HAL_UART_Transmit_DMA(&huart4, &UART4_array[0], UART4_ARRAY_SIZE);"

it sends only once , next time it do not work. Where i am doing wrong ? am I using wrong syntax ?

Please help me.

    This topic has been closed for replies.
    Best answer by Imen.D

    Hello @NKann.1​ ,

    Please consider the following example and article:

    Hope this helps you :)

    Imen

    5 replies

    Imen.DAnswer
    Technical Moderator
    June 23, 2021

    Hello @NKann.1​ ,

    Please consider the following example and article:

    Hope this helps you :)

    Imen

    NKann.1Author
    Visitor II
    June 24, 2021

    Thanks a lot Imen DAHMEN

    Technical Moderator
    June 24, 2021

    You are welcome :)

    Graduate
    September 14, 2023

    Dear @NKann.1 , I facing the same problem with stm32h725ze. I've tried to implement the suggested solutions but nothing was effective... The strange thing is that configuring DMA as circular the communication runs...
    How did you solve your issue in this case?

    Explorer
    September 14, 2023

    To transmit USART/UART with DMA using HAL, you need to enable the global interrupt for the USART/UART you are using. This is necessary because the HAL library, when using DMA, sets huart->gstate to HAL_UART_STATE_BUSY_TX and does not set it back to HAL_UART_STATE_READY. You can do this manually or enable UART global interrupts automatically by configuring NVIC settings in your .ioc file.

    Graduate
    April 5, 2024

    Thank you for this

    Graduate
    September 14, 2023

    Thanks @Juanjo97 , now it's working!

    Explorer II
    October 1, 2023

    Try my new multi-port uart dma library which works on f1,f4,h7 and can be easily modified through defines to support more series: https://github.com/georgy-moshkin/stm32uart 

    Configure UART ports using stm32cubeide, enable global interrupts, dma, and circular mode for RX channel. Use COM_Init with HAL's huart1, huart2, etc. pointers and you can start sending/receiving from multiple uart ports using simple functions.

    Tutorial on how to use can be found here: https://youtu.be/ZlsmW7s1N10