AnsweredAssumed Answered

Stm32cubeL0 loop in USART IT

Question asked by le_gall.gwendal.001 on Sep 11, 2014
Latest reply on Oct 28, 2014 by Montassar BEN ROMDHANE
Im using STM32Cube_FW_L0_V1.1.0 on a STM32L052C8T6

Why there is some loops into TX and RX IT functions?

For example:
in  UART_Receive_IT() At the end of the reception there is:

 while(HAL_IS_BIT_SET(huart->Instance->ISR, UART_FLAG_RXNE))
      {
      }


and in   UART_Transmit_IT() at the end of the sending there is a call to:
UART_WaitOnFlagUntilTimeout(). which is a blocking function

It is very dangerous to have such loop in a IRQ handler it can cause an overrun or worst.
For example when the last Byte is transmit you can't receive any byte without having an overrun because the IT handler is waiting for the TX Byte to be transmit :(

Is it done on purpose or have you an explanation for this?

Gwendal

Outcomes