cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with UART1 on STM32F303RT8

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?

2 REPLIES 2
Mike_ST
ST Employee

Hello,

Please check F303 reference manual to check USART ISR register, section 29.8.8

https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf

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.

You must clear the overrun flag, otherwise the receiver won't work.

JW