cancel
Showing results for 
Search instead for 
Did you mean: 

Uart data register flush out

Alex_reynold
Associate III

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

9 REPLIES 9
TDK
Guru

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

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

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".
Alex_reynold
Associate III
  • Not satisfied with non tech solutions 

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?

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 

 

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

I will check one minute

hi ,

Yes I checked buad rate is correct.thats why sensor is responding properly which is verified via logic analyser