Skip to main content
Graduate
March 11, 2025
Question

Uart data register flush out

  • March 11, 2025
  • 3 replies
  • 1194 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.

    3 replies

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

    Graduate
    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

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

    Graduate
    March 11, 2025
    • Not satisfied with non tech solutions 
    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?

    Graduate
    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 

     

    Super User
    March 11, 2025

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