USART Two Interrupt Overflow Errors

Using two USART systems operating at 115200 baud on the STM32F2, one for communication with the radio module and one for serial communication with the PC. The clock frequency is 120 MHz.

When receiving data from both USARTs, overflow errors on one USART or the other may occur at the same time. When doing some quick envelope calculations, there should be enough time to handle both, because interrupts just copy the bytes into the circular buffer.

Both in theory and in measurement, the interrupt code for pushing a byte into the buffer should / should be executed in the order of 2-4 ฮผs, at 115200 baud we have about 70% for processing each char.

Why do we see random ORE on one or the other USART?

Update - additional information:

  • There are currently no other ISRs in our code.
  • We start Keil RTX with a systick interrupt configured to start every 10 ms.
  • We will not disable interrupts at this time.
  • According to this book (Cortex-M Processor Designer's Guide), latency interpolation is about 12 cycles (not very fatal)

Given all of the above 70us, at least 10 times in the time that we do to clear interrupts, so I'm not so sure that it is so easy to explain. Should I conclude that there must be some other factor that I am experiencing?

MDK-ARM - version 4.70

The systick interrupt is used by RTOS, so from time to time another ISR does not need 2-3 ยตs for each byte.

+7
interrupt embedded serial-port stm32
source share
1 answer

I ran into a similar problem like yours a few months ago on a Cortex M4 (SAM4S). I have a function that is called at 100 Hz based on a timer interrupt.

At the same time, I had a UART configured to interrupt when receiving a char. The expected UART data was 64 byte long packets and interrupted the delay caused on each char, so my update function of 100 Hz worked at a frequency of about 20 Hz. 100 Hz is relatively slow on this particular processor with a frequency of 120 MHz, but the interrupt on each char caused significant delays.

I decided to configure UART to use the PDC (Peripheral DMA controller), and my problems disappeared instantly.

DMA allows UART to store data in memory WITHOUT interrupting the processor until a lot of overhead is completely saved.

In my case, I told PDC to store UART data in a buffer (byte array) and set the length. When the UART filled the buffer through the PDC, the PDC issued an interrupt.

In PDC ISR:

  • Give a new empty PDC buffer
  • Restart the UART PDC (so you can collect data while we do other things in isr)
  • memcpy full buffer in RINGBUFFER
  • Exit ISR

As the swineone recommended above, implement DMA and you will enjoy life.

+1
source share

All Articles