Skip to main content
Denis Gottardello
Associate III
November 2, 2018
Question

HAL_UART_Transmit but nothing is sent

  • November 2, 2018
  • 6 replies
  • 1941 views

Hi. I'm using these lines of code

Result= HAL_UART_Transmit(serial, BufferSerialWrite, BufferSize, HAL_MAX_DELAY);

to send data but, after some hours, nothing exits from the uart. I have to reboot the mcu.

How can I resolve this problem?

The line of cose

HAL_UART_Init(serial);

hasn't got any effect

    This topic has been closed for replies.

    6 replies

    Tesla DeLorean
    Guru
    November 2, 2018

    Lots to work with here..

    What STM32 part?

    Does it return an error? Works for hours and stops, or never works?

    Check status/errors reported in USART SR, inspect in debugger.

    Sure it is not another problem? Like getting stuck in Hard Fault Handler, or in interrupt context.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Denis Gottardello
    Associate III
    November 2, 2018

    It is a STM32F091. It works for many hours. I obtain always Result= HAL_OK

    Denis Gottardello
    Associate III
    November 2, 2018

    I will retry using the debugger.

    Bob S
    Super User
    November 2, 2018

    You do realize that HAL_MAX_DELAY will tell the function to wait more than 49 DAYS before timing out? Try setting this to a more reasonable value and see if you then get an error returned from HAL_UART_Transmit().

    Look at the source for HAL_UART_Transmit(), see where it loops waiting for a flag or timeout. In fact, run with your debugger, wait till it "hangs" then break. That should show you which flag it is waiting for. The BIG question is what that flag isn't getting set/reset.

    That is *IF* the problem is in the HAL_UART_Transmit() function. Otherwise it may be in a fault or interrupt handler as @Community member​ mentioned.

    Denis Gottardello
    Associate III
    November 7, 2018

    Maybe the problem was about the wrong setup of the mcu clock.

    in mozbek we trust
    Associate III
    November 7, 2018

    Did you check oscillator on your Tx pin can you see any messages there ?