Skip to main content
Jiannong Zhou
Associate III
August 31, 2022
Question

STM32F303 UART 3 receiver hang without RX interrupt after run 1-2 hours.

  • August 31, 2022
  • 8 replies
  • 2310 views

I am using my boards with STM32F303VBT6, There is a UART 3 hang after run for 1-2 hours. There is no UART interrupt of the receiver. I monitored the RS232 signal is there.

After reset the receiver board, the receiving date can be recovered.

What is the possible reason to cause no UART 3 interrupt?

Best regards,

Jiannong

This topic has been closed for replies.

8 replies

Tesla DeLorean
Guru
August 31, 2022

>>What is the possible reason to cause no UART 3 interrupt?

Some error status' flagged which you fail to clear.

Show USART3->SR in these situations

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Jiannong Zhou
Associate III
August 31, 2022

Thanks Tesla for your suggestion. I will check it.

Tesla DeLorean
Guru
August 31, 2022

Things like framing, parity, noise, etc

Get flagged, and need clearing indivdually.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Jiannong Zhou
Associate III
September 1, 2022

Hi Tesla,

When the issue happened, HAL_UART_RxCpltCallback() does not call back again.

// UART call back

void HAL_UART_RxCpltCallback (UART_HandleTypeDef *huart)

{

if(huart->Instance == USART3)

{

....

}

}

How to check ISR, NE, ORE, FE and clear them?

Jiannong

Jiannong Zhou
Associate III
September 1, 2022

Hi Tesla,

  1. Normal work: ISR = 0x6210D0
  2. Issue happens: ISR = 0x6210F8

Jiannong

Jiannong Zhou
Associate III
September 1, 2022

Hi Tesla,

The difference is D3 and D5 set.

USART_ISR_ORE  ((uint32_t)0x00000008) /*!< OverRun Error */

USART_ISR_RXNE ((uint32_t)0x00000020) /*!< Read Data Register Not Empty */

I try to set USART3->ISR = 0. but it does not work.

  1. How to clear these bits?
  2. Any bits to be cleared in void HAL_UART_RxCpltCallback (UART_HandleTypeDef *huart) function

Jiannong

Tesla DeLorean
Guru
September 1, 2022

I believe all of this is covered in the Reference Manual for the parts

char GetChar(void)
{
 if (USART_RS232->ISR & USART_ISR_ORE) // Overrun Error
 USART_RS232->ICR = USART_ICR_ORECF;
 if (USART_RS232->ISR & USART_ISR_NE) // Noise Err
 USART_RS232->ICR = USART_ICR_NCF;
 if (USART_RS232->ISR & USART_ISR_FE) // Framing Error
 USART_RS232->ICR = USART_ICR_FECF;
 
 if ((USART_RS232->ISR & USART_ISR_RXNE) == 0)
 return(0);
 
 return((char)(USART_RS232->RDR & 0xFF));
} 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Jiannong Zhou
Associate III
September 1, 2022

Hi Tesla,

Thank you so much for your detailed information. I will try it out.

Jiannong

Jiannong Zhou
Associate III
September 3, 2022

Hi Tesla,

I tested it to clear the error bits - USART_ISR_ORE and USART_ISR_RXNE. it can run over night. No problems.

I have two questions,

  1. What does cause USART_ISR_ORE - over run error?
  2. Is it correct that USART_ISR_RXNE error is caused by USART_ISR_ORE error?

Jiannong

Tesla DeLorean
Guru
September 3, 2022

RXNE is RX Not Empty, so indicates data available.

O​RE suggests you missed the service window, ie RXNE already signaling and more data arrives with no place to put it.

C​heck that you don't have blocking code in a higher priority interrupt or callbacks.

K​eep handlers very quick/cheap and put them in a group that can preempt slower and less critical ones.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Jiannong Zhou
Associate III
September 11, 2022

Hi Tesla,

Now I cleared these two bits when each interrupt routine calls. At least the communication does nots stop.

I need to do more detailed investigation to find which higher priority interrupt or callbacks to cause this issue.

Thank you so much for your advice.

Thanks,

Jiannong