Question
STM32 USART Interrupt Error
Posted on September 26, 2014 at 00:43
Hi,
I am having issue with the USART interrupt handler in my project. It seems to get stuck in the interrupt handler routine. The status register value is set to 0x1d8 but I don't seem to be able to clear the error state. The interrupt routine used is shown below and I am using the USART_GetITStatus to read error flags/rxne andtc from the status register and USART_ReceiveData to read the data. The communication seems to work for over an hour but then get stuck in the interrupt handler. Paulvoid rs485UsartIRQHandler(void)
{
if (USART_GetITStatus(RS485_USART, USART_IT_PE) == SET)
{
USART_ReceiveData(RS485_USART);
millisSinceLastReceive = 0;
}
if (USART_GetITStatus(RS485_USART, USART_IT_FE) == SET)
{
USART_ReceiveData(RS485_USART);
millisSinceLastReceive = 0;
}
if (USART_GetITStatus(RS485_USART, USART_IT_NE) == SET)
{
USART_ReceiveData(RS485_USART);
millisSinceLastReceive = 0;
}
if (USART_GetITStatus(RS485_USART, USART_IT_ORE) == SET)
{
// Dummy read to clear ORE flag
USART_ReceiveData(RS485_USART);
millisSinceLastReceive = 0;
}
if (USART_GetITStatus(RS485_USART, USART_IT_RXNE) == SET)
{
uint8_t newData = USART_ReceiveData(RS485_USART);
Ringbuf_Put(receiveBuffer, &newData);
millisSinceLastReceive = 0;
}
if (USART_GetITStatus(RS485_USART, USART_IT_TC) == SET)
{
DMA_Cmd(RS485_TX_CHANNEL, DISABLE);
USART_ITConfig(RS485_USART, USART_IT_TC, DISABLE);
GPIO_ResetBits(RS485_DE_PORT, RS485_DE_PIN);
transmitterBusy = false;
}
}