cancel
Showing results for 
Search instead for 
Did you mean: 

UART Receive interrupt stuck issue

jeevankumar
Associate II

As per my understanding of stm32 uart driver interrupt code the usual process for receive interrupt is,

1. HAL_UART_Receive_IT:
It checks if huart->RxState is HAL_UART_STATE_READY.
If true, it sets huart->RxState to HAL_UART_STATE_BUSY_RX.

2. When Data is received into DataRegister HAL_UART_IRQHandler calls UART_Receive_IT.

3. UART_Receive_IT:
checks if huart->RxState is HAL_UART_STATE_BUSY_RX.
If true, and when all data bytes are received, it sets huart->RxState to HAL_UART_STATE_READY.

Issue Scenario: Suppose due to some noise on UART line USART_SR_RXNE bit is set and HAL_UART_IRQHandler is triggered, and it calls UART_Receive_IT. Now UART_Receive_IT checks if huart->RxState is HAL_UART_STATE_BUSY_RX , its Not since HAL_UART_Receive_IT was not called by user. In this case the UART_Receive_IT exits without doing anything and HAL_UART_IRQHandler keeps getting triggered repeatedly since USART_SR_RXNE is not cleared and execution is stuck. 

Am I missing something here? or by design stm32 uart interrupt is stuck and system hangs.

I'm using STM32F407IGTx microcontroller. 

Kindly advice.

0 REPLIES 0