Hi
I recently encountered an issue while using LPUART as a serial port and connecting it to a computer through a serial cable. I was using the computer's serial software for input , and found that:
In case of power off, plug in the serial TX and RX cables and then power on, At this time, the input and output can be normal without any problems.
But after powering on, unplug and then insert the RX cable, the FE bit of STAT will remain in an abnormal state. Since I cannot determine when the user will unplug and reinsert the serial port cable in actual situations, I do not have a good time to reset the FE bit. However, when initializing the CTRL register, I turned off the FEIE interrupt, so even if there is an abnormality in the FE bit of STAT, it will not generate an interrupt, which has little impact on my program
I wrote a test code, let the board cycle output data to the serial port, and found that when the TX cable was unplugged and plugged in, the STAT status was normal, After unplugging and plugging in the TX cable, the data could be output normally, but when the RX cable was unplugged and plugged in again, the FE was abnormal. Therefore, my problem is as follows:
1. What specific error does the Framing Error corresponding to the FE bit refer to? Can you give an example of any other situations that can be triggered?
2. Taking on the first question, what impact will it have on the LPUART driver if I keep not clearing the FE bit?
Looking forward to your reply
Thanks
Solved! Go to Solution.
Hi @JayJay_H
Recommendations are to avoid connecting/disconnecting wires while operating and to clear the FE flag.
1. The Framing Error is reported when the received char has 0 where a stop bit should be:
This flag is triggered because the UART instance is still waiting on the stop bit for the transmission. This can also be caused by clock skew, if the transmitter clock and receiver clock are not derived from the same source, then one will run faster than the other.
2. When receiving UART data (or serial data in general) it is recommended to always check for errors and clear the flag (+ deal with the error) first. This will not necessarily affect transmissions, but it should be checked and cleared, as functionality is not guaranteed.
Best regards,
Julián
Hi @JayJay_H
Recommendations are to avoid connecting/disconnecting wires while operating and to clear the FE flag.
1. The Framing Error is reported when the received char has 0 where a stop bit should be:
This flag is triggered because the UART instance is still waiting on the stop bit for the transmission. This can also be caused by clock skew, if the transmitter clock and receiver clock are not derived from the same source, then one will run faster than the other.
2. When receiving UART data (or serial data in general) it is recommended to always check for errors and clear the flag (+ deal with the error) first. This will not necessarily affect transmissions, but it should be checked and cleared, as functionality is not guaranteed.
Best regards,
Julián
Hi @Julián_AragónM
Thank you for your support.
Best Regards.
Joshua