Skip to main content
Visitor II
April 17, 2026
Question

Issue with STM32 UART Communication and Data Loss in Continuous Transmission

  • April 17, 2026
  • 3 replies
  • 112 views

I am currently working on an STM32-based project using UART for continuous data transmission between the microcontroller and a PC application.

The system works fine initially, but I am facing intermittent data loss and incomplete packets during long-running communication. The issue becomes more noticeable when the baud rate is increased or when multiple interrupts are active in the system.

What I have already tried:

  • Verified baud rate and clock configuration in STM32CubeMX
  • Enabled UART interrupt-based receiving
  • Increased buffer size for RX handling
  • Checked wiring and physical connection stability

Despite this, the problem still occurs randomly after some time of operation.

I would like to ask the community:

  • What are the best practices for stable UART communication in STM32 under continuous data flow?
  • Should I switch to DMA-based UART instead of interrupt mode for better reliability?
  • Are there any known issues with buffer overflow or interrupt priority that could cause this behavior?

Any guidance or real-world experience would be greatly appreciated.

3 replies

TDK
Super User
April 17, 2026

Use HAL_UARTEx_ReceiveToIdle_DMA with a circular buffer. You will get no data loss, provided you handle the data in a reasonable time frame.

"If you feel a post has answered your question, please click ""Accept as Solution""."
mƎALLEm
Technical Moderator
April 17, 2026

Hello,

What STM32 part number are you using?

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
Andrew Neil
Super User
April 17, 2026

How do you detect the loss?

What testing have you done to find where the data is being lost:

  • on the PC side ?
  • on the STM32 side ?
  • both ?

Does the loss correlate with anything else happening in the system?

Are UART errors occurring (framing, overrun, etc) ?

Is your interrupt handling tight and efficient?

Are your interrupt priorities well thought out?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.