Skip to main content
Graduate
February 13, 2025
Solved

Do i really need to use HAL_Delay() after each HAL_UART_Transmit()?

  • February 13, 2025
  • 3 replies
  • 1085 views

so i was following an online tutorial (from digikey, where they teach how to use dma) and in it the values from ADC is transmitted through DMA to a buffer of decent size (4096byte). But it seems they always use the hal delay function after using uart transmission. Is this necessary, i noticed that without the delay function my frequency goes from 1khz to 7khz and i dont see any issues with the transmission too.

i mentioned about the dma from adc in case its relevant for using the delay function in uart

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    No

    HAL_UART_Transmit(), blocks until completion

    HAL_UART_Transmit_DMA(), returns immediately, so you're supposed to wait for the completion or error callbacks to understand when it finished. You call also only have a single operation in-flight at once, and you should pay attention to the scope/life of the buffer you're passing.

    3 replies

    Super User
    February 13, 2025

    No, not really. If you want pauses between sampling the ADC, provide the intervals in any way.

    By the way, this forum is the perfect place to ask about internal ADCs of STM32. No digikey or any amateur website even comes close.

     

    Graduate II
    February 13, 2025

    No

    HAL_UART_Transmit(), blocks until completion

    HAL_UART_Transmit_DMA(), returns immediately, so you're supposed to wait for the completion or error callbacks to understand when it finished. You call also only have a single operation in-flight at once, and you should pay attention to the scope/life of the buffer you're passing.

    Super User
    February 13, 2025

    @AdilMC wrote:

    so i was following an online tutorial (from digikey, where they teach how to use dma)


    Please give a link - so we can see it in context.

    I think you can post questions on Digikey's tutorials - did you try asking them why they did it?

    Graduate II
    February 14, 2025

    I bet the delay is more for the user to see the data changing in the console with some pause before sending the next data. Otherwise the packets will be scrolling too fast to see the actual data. 

    Typically our telemetry data is sent every 10ms, sometimes 1ms. Way to fast to view. So I have a command to change the telemetry send rate, like 1000ms only for debug purposes. Way easier to view the data.