cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected triggering of HAL_UART_IRQHandler using HAL_UART_Receive_IT and HAL_UART_RxCpltCallback

TomC
Senior

Board: Nucleo-WB55

I'm attempting to continuously interrupt when data is received via UART.

The program is able to receive data when it is sent without fail, however the Rx interrupt is triggered when new data is not sent. I implement the following logic in my HAL_UART_RxCpltCallback routine:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{
	strcpy((char*)command, (char*)UART1_rxBuffer);							
	rx_flag = 1;												
	HAL_UART_Receive_IT(&huart1, UART1_rxBuffer, 5);			
}

I call HAL_UART_Receive_IT after each complete call back so that a new receive request is ready. My methodology is clearly missing something, perhaps clearing a buffer or resetting a flag somewhere?

2 REPLIES 2
TomC
Senior

Turns out this was caused by another UART that was being used triggering the same interrupt routine. I am yet to work out how to fix it. Will update.

Fixed by placing conditions in the call-back that check the UART Handle that triggered the interrupt, allowing me to execute specific logic for each UART.