cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle UART errors?

SGonz.2
Associate II

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!

4 REPLIES 4
Andrew Neil
Evangelist III

"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 ...
Bastien LS
Associate III

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 ...

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.