Hi Sergey,
thanks for the clarification.
We are running the GX3 at 500Hz, at 921600 baud, each packet from IMU has 67 bytes, so it is quite a lot of data.
The most likely source seems to be the Overrun Error on the UART RX line from the GX3.
Right now the code for usart_interrupt handles only two cases in the status register (USART_SR): Transmit Data reg. Empty (TXE) and Read data register Not Empty (RXNE). Thus if the Overrun Error (ORE) or any other error happens, it is not handled properly (i.e. read USART_SR and read USART_DR) so the code hangs there.
I tried to fix the problem by adding a check for ORE:
if (((USART_CR1((u32)p->reg_addr) & USART_CR1_RXNEIE) != 0) &&
((USART_SR((u32)p->reg_addr) & USART_SR_ORE) != 0)) {
usart_recv((u32)p->reg_addr);
}
and it seems to do the job. However, it doesn't take care of all the cases either.
Do you know what kind of state machine would be the best to implement to take care of all possible USART_SR flags while keeping the code short and fast?
Thanks
M