2022-08-29 06:22 AM
Dear Mrs, Mr,
I'm working with a Riverdi discovery board with a STM32. I'm developing a serial protocol for which I'm using interrupt for reception.
But I guess this is not the best way to clean buffer, state and pending interrupts. Can you advise of the best way to do it ?
Thank you in advance,
Pascal
Solved! Go to Solution.
2022-08-30 12:52 AM
Hi Pascal,
You could check the ISR (or SR register, depending on the STM32 serie you are using) of UART instance when you execute the 2nd reception (the failing one). Maybe some errors are already present in register, preventing the reception to be properly handled. I'm thinking about the Overrun flag (indicating that some data where received but not read on time from RDR). This could happen if additional data have been received after 1st reception is complete. When this flag is set (some data have been lost), but reception is frozen under the error is cleared.
If this happens in your case, you could clear the flag by resetting flag in ICR (or CR register) prior restarting 2nd reception, for instance using the dedicated macro :
__HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) with UART_CLEAR_OREF as flag.
Regards
Guenael
2022-08-30 12:52 AM
Hi Pascal,
You could check the ISR (or SR register, depending on the STM32 serie you are using) of UART instance when you execute the 2nd reception (the failing one). Maybe some errors are already present in register, preventing the reception to be properly handled. I'm thinking about the Overrun flag (indicating that some data where received but not read on time from RDR). This could happen if additional data have been received after 1st reception is complete. When this flag is set (some data have been lost), but reception is frozen under the error is cleared.
If this happens in your case, you could clear the flag by resetting flag in ICR (or CR register) prior restarting 2nd reception, for instance using the dedicated macro :
__HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) with UART_CLEAR_OREF as flag.
Regards
Guenael