cancel
Showing results for 
Search instead for 
Did you mean: 

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

AdilMC
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5
Pavel A.
Evangelist III

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.

 

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

@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?

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.

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.

this is the video, the whole series is pretty neat for an absolute beginner like me but i dont think they reply in the comment section. the delay is also something i saw in other videos related to UART transmission and hence the doubt