cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug in UART of the latest F4xx_HAL_Driver (v1.4.1, cubef4 v1.9.0)

Posted on November 11, 2015 at 23:36

Hi,

I got stuck for 4 hours in this problem and now found why:

When I use the HAL_UART_Transmit_IT() function and at the same time something arrives in the RX without the HAL_UART_Receive_IT() being called, it causes an overrun error and holds the execution inside the UART IRQ Handler.

This happens because the HAL_UART_Transmit_IT() activate Error interrupts (line 829 of the ..hal_uart.c) (why? this is not intended only for reception?), and when an overrun error occurs, the HAL_UART_IRQHandler() will clear the error and set the ErrorCode to HAL_UART_ERROR_ORE (line 1194), this causes the State to be set to HAL_UART_STATE_READY right before calling the user ErrorCallback function (line 1226), but because the error occurred in the middle of a transmission, the TXE interrupt still running, and now the function UART_Transmit_IT() (line 1210) is being called but will do nothing because of the new set State, keeping the interruption in an infinite loop.

For the moment, my workaround to avoid change the library itself is to implement a function to restore the State and clear the ErrorCode at the ErrorCallback function:

void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)

{

if(huart->TxXferCount>0)

{

huart->State = HAL_UART_STATE_BUSY_TX;

}

huart->ErrorCode = HAL_UART_ERROR_NONE;

}

Please, somebody confirm that this is a bug and I'm not using the lib in a wrong way, just to be sure that I'm not crazy

Clive1 ????

Thanks.

#conscientious-objector
2 REPLIES 2
Posted on November 12, 2015 at 00:21

Clive1 ????

Sorry, can't help you with HAL/Cube stuff, not touching it with a ten-foot pole.

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Amel NASRI
ST Employee
Posted on November 12, 2015 at 14:25

Hi Laureg,

This seems to be the same issue as the one reported in [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/STM32F4%20Cube%20HAL%20UART.%20Is%20it%20a%20bug%20or%20am%20I%20missing%20something&currentviews=35]this discussion.

Please note that this is under review in order to provide the appropriate solution..

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.