Unexpected triggering of HAL_UART_IRQHandler using HAL_UART_Receive_IT and HAL_UART_RxCpltCallback
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-31 3:17 PM
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?
- Labels:
-
STM32WB series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-31 3:47 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-01 2:18 PM
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.
