AnsweredAssumed Answered

HAL-Driver UART-receiving via interrupt issue: RXNE-flag is cleared too soon.

Question asked by Marco Trick on May 24, 2018
Latest reply on May 24, 2018 by Marco Trick

Hello ST Community,

I'm trying to get started with the HAL-Library using CubeMX on an STM32F4-Discovery board. I'm using the UART interface USART2 and try to receive data via interrupts. The interrupts are fired as usual (so i think my configuration works).

But when the HAL-Driver calls HAL_UART_IRQHandler(&huart2) in stm32f4xx_it.c, the RXNE-flag is cleared, and the processing of the flag inside HAL_UART_IRQHandler(&huart) fails. I know, that the RXNE flag is cleared by hardware, when the SR-register is read. But in my case, the RXNE-flag is cleared right at the moment of the function-call.

As a result, the function UART_Receive_IT() is never called; same with the callback-function. Has anyone any idea what I am doing wrong? Or is there a bug in the HAL-library?

I've tried to use the example of the library for UART on an STM32F4-Discovery, but there is the same problem.

Thank you very much in advance!

Outcomes