2021-08-11 12:57 AM
Hi
I am working on getting and processing raw serial data on a STM32F303RT8 MCU. The interrupt is firing but I am not able to properly read data from the Serial interface.
Every time the ISR fires, the value of "sr" is 216 except for the first time which is 248.
void USART1_IRQHandler(void)
{
uint8_t tmp = 0;
uint16_t sr = USART1->ISR; // must be latched before reading DR
if (sr & USART_ISR_RXNE)
{
//Reading 1 byte from USART and Assign to Buffer
tmp = USART1->RDR;
usart1_rx_buffer[index_uart1] = tmp;
index_uart1++;
prev_data = tmp;
}
}
Any suggestions to get this issue fixed?
2021-08-11 01:26 AM
Hello,
Please check F303 reference manual to check USART ISR register, section 29.8.8
In case you are using the HAL, you may want to call HAL_USART_IRQHandler(USART_HandleTypeDef *husart) function from USART1_IRQHandler to clear the flags.
2021-08-11 03:30 AM
You must clear the overrun flag, otherwise the receiver won't work.
JW