Skip to main content
Associate III
March 11, 2025
Question

Uart data register flush out

  • March 11, 2025
  • 9 replies
  • 1257 views

Hi,

I am currently using f446 nucleo board with  some over uart interface.I am able to send the desired frames over Uart to sensor and sensor is properly responding by sending positive acknowledgement to each uart sent frames.And this verified in logic analyser.But while receiving it on rx pin mcu is not able detet t bytes properly.even thought desired bytes are available over uart rx lin as it is verified using logic analyzer 

Thing I am missing is I am not flushing out the dayat ragister and buffers before reading data.

Is there any HAL API  to perform this flush operation

May be for reference, myserial.flush api of arduino.this functionality I am looking for

Thanks alex

This topic has been closed for replies.

9 replies

TDK
March 11, 2025

> But while receiving it on rx pin mcu is not able detet t bytes properly.

In what way are they incorrect?

The UART does not need flushed before reading data. If data is incorrect, it indicates a code bug or an issue with the data on the line.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
March 11, 2025

For example if you sensor is sending 0x06 and 0x04.mcu is reading it as 0x06 and 0x0e.But over logic analyzer it is i am getting 0x06 and 0x04

TDK
March 11, 2025

Are these actual examples? I would expect 0x04 and 0x0E to differ by 1-2 bits if it's a clock mismatch but those two values are quite different in binary. If it's completely different character, there is likely an issue with the signal coming in. A logic analyzer would clear it up.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
March 11, 2025
  • Not satisfied with non tech solutions 
Andrew Neil
Super User
March 11, 2025

Also look at the signal using an oscilloscope - to see if there's noise or any other "analogue" problems with the signal.

Have you carefully checked the baud rates of both devices?

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
March 11, 2025

Thanks for the reply,

No such noise is coming.

 

After power recycleing.(Power on reset), for first iteration, uart peripheral of mcu is reading properly 

 

Andrew Neil
Super User
March 11, 2025

Again, Have you carefully checked the baud rates of both devices?

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.