I am using an STM32F105 to communicate with a Linx GPS chip using a UART.
If I don't use interrupts (if I just poll the RX flag) then it works just fine. But I'm getting unexpected results when trying to use interrupts.
For example, if I only enable the RXNE ("RX not empty") interrupt using
USART_ITConfig(USARTx, USART_IT_RXNE), then the code should only vector to the ISR for this one specific event. But the interrupt is being triggered for an Overrun condition, too.
As far as clearing the flags, it seems that the method depends on the flag.
To clear the Overrun flag (
USART_IT_ORE), the User Manual explains that I should first read the
USARTx_SR register, then read the
USARTx_DR register. This does work; the flag is cleared.
There is also a
USART_ClearITPendingBit() function, but it only accepts a small subset of flags.
There are eight different interrupt sources that can be selectively enabled, and ten different flags. Is there a summary somewhere of how to manage all of these flags?