I am using the UART4 module of an STM32F105. I'm using the RXNE ("RX Buffer Not Empty") interrupt to grab data as it comes in. It's working as expected.
When the RXNE interrupt is enabled it also enables the Overrun interrupt (ORE). This also appears to work as expected.
The ORE status flag is mapped as USART_FLAG_ORE
. The corresponding interrupt flag is USART_IT_ORE
. If the RXNE interrupt is enabled, when the Flag bit gets set it should cause the IT bit to also get set. Copied from the User Manual:
I'm handling the interrupt like so:
void usartISR(void)
{
// Did we receive data?
if(USART_GetITStatus(UART4, USART_IT_RXNE) == SET)
{
// Add it to the active buffer
}
// Did the receiver overrun?
else if(USART_GetITStatus(UART4, USART_IT_ORE) == SET)
{
// Clean up and clear the Overrun condition
}
// No other triggers have been enabled
else
{
ErrorHandler(ERR_BAD_INTERRUPT);
}
}
The problem happens if the ORE flag is already set when I enable the interrupt:
{
// The USART_FLAG_ORE bit is already set
// The following command causes an immediate vector to the ISR:
USART_IT_Config(UART4, USART_IT_RXNE, ENABLE);
}
The code vectors to the ISR, but the USART_IT_ORE
flag doesn't seem to get set. The ISR merrily skips to the end and calls the error handler. If I look into the USART_CR registers, none of the other interrupt events are enabled. If I bypass the error handler, the code repeatedly vectors to the ISR even though no IT flags are set.
Why is the ISR getting triggered without the USART_IT_ORE
flag getting set? Am I missing something obvious?
USART_FLAG_ORE
was set, implying thatUSART_IT_ORE
should have been set, but theUSART_GetITStatus()
function still returned a negative... \$\endgroup\$USART_FLAG_ORE
bit wasn't cleared by any of the reads. \$\endgroup\$USART_IT_ORE_RX
instead ofUSART_IT_ORE
inGetITStatus()
. The latter seems to be a legacy definition in one library i found \$\endgroup\$USART_IT_ORE
is the one used in my version of the SPL (v3.5.0). I did a search through the library forUSART_IT_ORE_RX
and came up with zero hits. I have found a workaround and posted it an an answer. Would you look at it and see if it tells you anything? Thanks again. \$\endgroup\$