I am using interrupt based UART IO (no DMA).

HAL_UART_Transmit_IT function sets EIE bit in CR3 register. According to STM32F407 datasheet (and real behaviour), this generates interrupt only in multi buffer mode (when DMAR bit is set). EIE enables interrupt generation for frame error (FE), overrun error (ORE), noise error (NE). This error, as I understand, only for receiving.

Part of HAL_UART_IRQHandler function:

/* UART Over-Run interrupt occurred ----------------------------------------*/
if((tmp1 != RESET) && (tmp2 != RESET))

  huart->ErrorCode |= HAL_UART_ERROR_ORE;

if(huart->ErrorCode != HAL_UART_ERROR_NONE)
  /* Set the UART state ready to be able to start again the process */
  huart->State = HAL_UART_STATE_READY;


HAL_UART_IRQHandler checks for each error. If error occurred and EIE bit is set, it resets UART state, but doesn't reset interrupt enabling bits, so TXE interrupt will be always generated, but UART_Transmit_IT function treats state HAL_UART_STATE_READY as invalid and doesn't do anything. Infinite loop.

Part of UART_Transmit_IT function:

static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart)
  uint16_t* tmp;
  uint32_t tmp1 = 0;

  tmp1 = huart->State;
  if((tmp1 == HAL_UART_STATE_BUSY_TX) || (tmp1 == HAL_UART_STATE_BUSY_TX_RX))
    return HAL_BUSY;

Is it a bug in Cube HAL?

  • \$\begingroup\$ three and a half years later and this is still a problem \$\endgroup\$ Commented May 17, 2019 at 20:40

2 Answers 2


It is a bug.

I asked same question on the ST forum: https://my.st.com/d5c15f59

They confirmed it.

  • \$\begingroup\$ The "my.st.com" link requires a login. I found this thread on the ST forum, which I think is the reporting of this problem, and is accessible without a login, so readers may find that useful. \$\endgroup\$
    – SamGibson
    Commented Oct 17, 2016 at 17:58

Did you try to download the lastest version of Cube HAL for your MCU?

My HAL_UART_Transmit_IT() function seems very different than yours. Maybe you have an older version with bugs.

Try access st.com and search for the lastest version of Cube HAL. Inside the archive you'll find some example with USART.

  • \$\begingroup\$ HAL_UART_Transmit_IT and UART_Transmit_IT are different functions. First only sets up interrupts, while second actually transmits data \$\endgroup\$
    – rublag
    Commented Nov 6, 2015 at 3:42
  • \$\begingroup\$ Yes, but you know that second function can only be call by other HAL function not direct by user? And i just open my HAL source files and find UART_Transmit_IT and its different than the part you paste above. Other option if you still think there is a bug is to write the same question on st forum. \$\endgroup\$ Commented Nov 6, 2015 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.