2025-03-27 12:00 PM - edited 2025-03-27 10:49 PM
Hi,
I had to recently work on an application that makes use of the UART, and encountered some issues in the HAL (most recent version provided by CubeMX):
1) Hal bug?
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c, Line 3825:3831
if (!(IS_LPUART_INSTANCE(huart->Instance))) {
/* Check that USART RTOEN bit is set */
if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U) {
/* Enable the UART Receiver Timeout Interrupt */
ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
}
}
Solved! Go to Solution.
2025-03-27 2:59 PM
In the current HAL G4 version the line numbers have moved - do you mean this place?
In some places the comment is wrong, the intent is to clear the RTO interrupt.
(2) Function HAL_UART_Transmit() is not meant to enable (and receive) error interrupts.
For complex use cases consider writing your own driver code, using the "HAL" source as learning material.
2025-03-27 2:59 PM
In the current HAL G4 version the line numbers have moved - do you mean this place?
In some places the comment is wrong, the intent is to clear the RTO interrupt.
(2) Function HAL_UART_Transmit() is not meant to enable (and receive) error interrupts.
For complex use cases consider writing your own driver code, using the "HAL" source as learning material.
2025-03-27 10:44 PM - edited 2025-03-27 10:48 PM
Hi Pavel, thank you for the quick reply.
1) Yes, is that one. I see, the one (code) or the other (comment) is surely off :)
I didn't realized the code was on GH, I would have opened the issue there :)
2) I see, thank you for the explanation.
Wow, that's a statement. I did not you consider your HAL learning material... good to know.
I think this makes the Rust adoption decision even easier for us :D
Thank you for your support.
2025-03-28 7:50 AM
@igiona-scewo About Rust, just one caution: it is the new Microsoft's darling. When you see that Microsoft likes and promotes something - drop it and run in the opposite direction!