cancel
Showing results for 
Search instead for 
Did you mean: 

Overrun error is frequently occured on STM32F415 even on a highest interrupt priority for USART1

Yang Yang
Associate II

Hello, ST experts

STM32F415 runs at 168MHz speed on custom board. And UART1 is used between MCU and a peripheral. The UART baudrate is 460800bps. And UART1 global interrupt is the highest priority interrupt except Non maskable interrupt and Hard Fault interrupt. HAL_UART_Receive_IT ​keeps running to receive data one byte a time from peripharal. But overrun error keeps on happening, what might be the reason?

Best Regards

Yang

1 ACCEPTED SOLUTION

Accepted Solutions

No, they have same pre-emption priority so one can not pre-empt the other.

View solution in original post

5 REPLIES 5

With those frequency and baudrate the MCU has ~3600 cycles to execute HAL's interrupt code and your callback function for each byte. If one of those takes too long then overruns will happen. Try to optimize your callback, or if it's HAL's issue try to use the LL library instead, or use DMA.

Hello

But the question is if another GPIO interrupt raises at an interval of 4ms, there is no Overrun error at all. But if the GPIO interrupt raises at an interval of 0.5ms, the overrun error appears, I really don't know why. This GPIO interrupt has a low priority than UART.

BR

Yang

What priority group are you using in NVIC settings? I mean, give attention to interrupt pre-emption settings. E.g. maybe your low priority GPIO interrupt is running and the UART interrupt occurs and it can not pre-empt GPIO interrupt because of priority group settings.

Hello

The USART1 pre-emption priority is 0, sub priority is 0. The GPIO pre-emption priority is 0, sub priority is 1. Is that correct?

BR

Yang​

No, they have same pre-emption priority so one can not pre-empt the other.