stm32 uart interrupt stops working after ~1 hour
I am using an STM32L073 chip. I have 2 UARTs but only the huart1's receive is using interrupts. I start the Rx interrupt at start-up and then the interrupts are being set at the end of the interrupt function. (see code below)
My issue is that after about an hour, the interrupts stop triggering. The rest of my program continues to work. The HAL_UART_ErrorCallback never gets called.
My huart1 is set up as 8E1.
The speed of messages that cause this problem is an 11 char message every second.
Is there any way I can identify why my interrupts are not triggering anymore? is there another HAL error function I can check in a thread to see if a flag was set somewhere that I can clear?
NOTE: huart1 is transmitting using "HAL_UART_Transmit(huart1, payload, length, TIMEOUT_100MS);
This function is in a thread that doesn't need to be fast, so I am not worried about using interrupts or DMA with this.
#define LENGTH_OF_MESSAGE 11
uint8_t rxBuffer[LENGTH_OF_MESSAGE] = {0};
void resetUartInterrupts()
{
memset(rxBuffer, 0, LENGTH_OF_MESSAGE);
HAL_UART_Receive_IT(huart1, rxBuffer, 1);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *uartHandler)
{
//check to see if action is recieved while waiting for it
if (rxBuffer[0] == 0)
{
if (isActionChar(rxBuffer[0]))
{
// now grab the rest of the message
HAL_UART_Receive_IT(uartHandler, &rxBuffer[1], LENGTH_OF_MESSAGE - 1);
}
else
{
//not an action character, keep waiting for one
resetUartInterrupts();
}
}
else
{
saveMessageToRxQueue();
//wait for next action char
resetUartInterrupts();
}
}
// this code is never called
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
if(huart == huart1)
{
resetUartInterrupts();
}
}