AnsweredAssumed Answered

STM32F4 UART HAL time race condition?

Question asked by yvraut.gerard on Mar 20, 2015
Latest reply on Apr 12, 2015 by yvraut.gerard
In multiple places in the UART HAL (in all the variants of HAL_UART_Receive) one can find the following code:   

/* Check if a transmit process is ongoing or not */
    if(huart->State == HAL_UART_STATE_BUSY_TX)
      huart->State = HAL_UART_STATE_BUSY_TX_RX;
      huart->State = HAL_UART_STATE_BUSY_RX;

This code may be interrupted in case of completion of transmit buffer, and the interrupt service routine may change the value of huart->State .  

The above code should be either protected from interrupt or better replaced by an atomic instruction (which seems fairly easy looking at the possible values of huart->state.