2025-03-11 1:38 AM
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
2025-03-11 2:50 AM
> 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.
2025-03-11 3:16 AM
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
2025-03-11 3:47 AM - edited 2025-03-11 3:47 AM
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.
2025-03-11 4:04 AM
2025-03-11 4:13 AM
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?
2025-03-11 4:34 AM
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
2025-03-11 4:39 AM
Again, Have you carefully checked the baud rates of both devices?
2025-03-11 4:48 AM
I will check one minute
2025-03-15 8:49 AM
hi ,
Yes I checked buad rate is correct.thats why sensor is responding properly which is verified via logic analyser