Skip to main content
SGonz.2
Associate III
June 23, 2022
Question

How to handle UART errors?

Hello!

I'm receiving data in UART Rx with DMA and I need to make it inmunne to disconnections. Now, sometimes I can recover the communication after a disconnection, but I need it always.

Using the debugger I realized that huart1.ErrorCode change its value from 0 to 2,4 or 6. I guess they are noise, frame and noise+frame(?) errors, and after this error the UART stops.

How can I handle this error with my HAL_UART_ErrorCallback and resume UART communication?

Thank you!

This topic has been closed for replies.

4 replies

Andrew Neil
Super User
June 24, 2022

"ErrorCode change its value from 0 to 2,4 or 6"

Sounds like a bit map ?

"I guess they are noise, frame and noise+frame(?) errors"

Would work for a bit map - surely, this must be described in the documentation?

"How can I handle this error"

That's really down to you - what makes sense for your particular application?

You might:

  • Add an error-correcting protocol
  • Add a protocol which requests retransmission
  • etc ...
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.
Associate III
June 24, 2022
Andrew Neil
Super User
June 24, 2022

It seems that wouldn't give any indication that a frame has been lost (eg, due to corruption)?

From the Wiki:

  • "Provide 'fail silent' reliability: if a frame is passed to the application it must have been received correctly, else it is discarded"

Also (under 'Flow Control'):

  • "Corrupted frames are discarded by the protocol"

https://github.com/min-protocol/min/wiki

This may or may not be a problem - depending on the application ...

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.
Associate III
June 27, 2022

Hi @Andrew Neil​,

The protocol has a "transport part" with "delivery guarantees". Although it is not clearly said on the wiki, from what I understood in the source code, provided that an option is activated (it is, by default), the sender of a packet will expect an ACK for each frame sent ; or will send the frame again and again, as long as the corresponding ACK is not received.