stm32f0xx-hal
stm32f0xx-hal copied to clipboard
Unable to manage overrun for USART
I'm trying to use the USART2 peripheral on my stm32f030RC. I'm not using interrupts, so from time to time an overrun interrupt is to be expected (and is acceptable); however I am unable to manage the error with the tools provided by the API.
When an overrun occurs the serial.read
method returns an error accordingly, but:
- the Peripheral.USART2 reference has been passed to the
Serial
object, so I cannot access its ICF register to clear the ORE bit. - I cannot set the OVRDIS bit and ignore every overrun because the
Serial
constructor resets the CR3 register (https://docs.rs/stm32f0xx-hal/0.14.1/src/stm32f0xx_hal/serial.rs.html#350); I cannot change it afterwards because the USART2 reference is gone and that bit cannot be changed while the peripheral is on.
How do I manage overrun errors? Either clearing the flag or disabling it altogether would be fine for me.
Edit: this problem would be resolved by PR https://github.com/stm32-rs/stm32f0xx-hal/pull/63