STM32 HAL Uart receive interrupt stops receiving at random times
I am using an F303RE and UART communications for a project.
I'm using all 5 uarts, all with the HAL-library interrupt based transmit and receive.
The main communication protocol is MAVLINK, with one of the UARTs being SBUS.
My issue:
After a random amount of time, a UART channel stops receiving messages.
It is also not always the same channel to stop, and it might be multiple channels to do so (not at the same time).
Note:
I'm dealing with this issue for 3 weeks now, without any progress.
I know the 'correct' way would be to write a new HAL, but I don't have resources or knowledge to do so at the moment.
I am using HAL_UART_RxCpltCallback, this way:
(There's HAL_UART_Receive_IT at the end of each reading function)
(I know the code isn't pretty, a switch-case would be a better fit for readability)
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
USART_TypeDef *uart = huart->Instance;
if(uart == USART1)
{
readUartOne();
}
else if(uart == USART2) // from PC
{
// do some stuff (not too much, though)
HAL_UART_Receive_IT(&huart2, &inBuff2[0], 1);
}
else if(uart == USART3) // from SBUS
{
readSbusPacket();
}
else if(uart == UART4)
{
readUartFourPacket();
}
else if(uart == UART5)
{
readNVPacket();
}
}I've tried to catch an interrupt override using some variables - I added an if(uart != huart->Instance) to see if the interrupt is being overridden.
But couldn't find any, so I assume it's not the case.
Please let me know if you have any ideas or tips on how to handle this.
