Skip to main content
Graduate II
January 30, 2024
Solved

Unexpected UART timeout error HAL_TIMEOUT with the STM32G0B1RET MCU

  • January 30, 2024
  • 1 reply
  • 3451 views

I completed an alpha prototype design with the NUCLEO-G071RB, the STM32 Nucleo-64 development board with a STM32G071RB MCU plus a custom daughter board. Hardware and software using the HAL library work well, so I moved on to the next step, a beta design: a custom board with the STM32G0B1RET MCU for extra memory.

The alpha source code was ported to the new MCU using the HAL library, and MX was used to adjust the pinout.
Result: the beta device establishes UART communication with the external device, but reports unexpected HAL_TIMEOUT errors:

err = HAL_UART_Receive(huart1, (uint8_t*) uart_RxBuffer, packLen, timeout);

The variable 'timeout' is 20 ms, and the oscilloscope shows that a response received within 4 ms. It should work, so why teh timeout error. (I assume the measurement unit is milliseconds.)

What can cause these timeout errors? Thank you!

    This topic has been closed for replies.
    Best answer by TDK

    Set the timeout to HAL_MAX_DELAY, see if it works. Probably it doesn't, which means data isn't coming in and the timeout is valid.

    > The alpha source code was ported to the new MCU using the HAL library, and MX was used to adjust the pinout.

    Guessing the pin isn't properly initialized but it could be any number of things including invalid clock.

    1 reply

    TDKAnswer
    Super User
    January 30, 2024

    Set the timeout to HAL_MAX_DELAY, see if it works. Probably it doesn't, which means data isn't coming in and the timeout is valid.

    > The alpha source code was ported to the new MCU using the HAL library, and MX was used to adjust the pinout.

    Guessing the pin isn't properly initialized but it could be any number of things including invalid clock.