HAL_UART_Receive_IT problem with size argument other than one
Hello,
I have just started with STM32 after some projects with AVR MCUs. I have recently noticed a strange behavior with "HAL_UART_Receive_IT" function. Everything works fine for me if the size argument is one, but for other values the overrun flag is set after few receptions.
If I for example give the size argument size=5 and send bytes in the chunks of three bytes like:
123<send> 123<send> 123<send> 123<send>
The overrun occurs somewhere during the fourth chunck. I dont understand why everything works perfectly and I never end up with ORE flag set if the size parameter is one. By looking at the HAL driver the interrupt routine should actually take slghtly longer when the size is one and with size=1 everything works always. Uart baudrate is only 9600. My debug code after initializations is just forever while loop with no content (while(1);) and my uart RX callback code is:
char rx_buff[100];
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1) // Ensure it's UART1
{
HAL_StatusTypeDef ret;
ret = HAL_UART_Receive_IT(&huart1, (uint8_t*)rx_buff, 5); //You need to toggle a breakpoint on this line!
}
}
Thank you and Best Regards
