“The protocol decoding function of the oscilloscope is not unfamiliar to everyone. Have you ever experienced that the waveform looks normal, the protocol parameters and the decoding settings are correct, but the decoding cannot be done normally? This article takes the UART protocol as an example to share the troubleshooting process of abnormal communication caused by baud rate drift.
“
The protocol decoding function of the oscilloscope is not unfamiliar to everyone. Have you ever experienced that the waveform looks normal, the protocol parameters and the decoding settings are correct, but the decoding cannot be done normally? This article takes the UART protocol as an example to share the troubleshooting process of abnormal communication caused by baud rate drift.
What is baud rate drift? It can be understood that the crystal oscillator of the component under test is deviated, causing the actual baud rate to be inconsistent with the normal baud rate. Why does baud rate drift cause communication abnormalities? This article starts from the waveform and takes you to self-check the decoding result.
1. Troubleshooting for abnormal communication caused by baud rate drift
Leading to such a real example, the serial port data sent by the PC is “0xEE 0x61 0x32 0xFF 0xFC 0xFF 0xFF”, and the oscilloscope decoded result is “0xEE 0x98 0xF6 0xFC 0xFF” to preliminarily determine the communication failure. But the protocol parameter settings and decoding settings are correct, why is there a phenomenon of inconsistent sending and receiving? In the following, the baud rate in the protocol parameter setting during decoding is set to 9600 bps, the actual value is 9600 bps, and the waveform diagram decoding result comparison of 10126 bps (as shown in Figure 1) is analyzed as an example, and the waveform is caused by sharing the baud rate drift. There is a deviation, which leads to the troubleshooting process of the cause of the communication abnormality.
Figure 1 Diagram of different waveform decoding results under the same decoding baud rate
Let me talk about the decoding principle of UART first. When the oscilloscope decodes the UART signal, it takes the falling edge after the idle level as the start bit, and then samples from the waveform at equal intervals, and takes the majority of the sampling points in the equal interval time period as the decoded value of the bit. For waveforms with different baud rates, the minimum data width is inconsistent. Time T = 1/sampling rate. The waveform with a larger actual sampling rate corresponds to a smaller time. Therefore, it can be seen from Figure 1 that the waveform with a baud rate of 10126bps looks like Shifted to the left. When the baud rate set during decoding is the same as 9600, the position of the sampling point is determined according to the baud rate of 9600. When the actual sampling rate deviates from 9600bps, the error will gradually accumulate, resulting in a deviation in decoding. The larger the data bit width you set, the easier it is to add errors.
Two, self-check baud rate method
Starting from the waveform, estimate the baud rate based on the minimum bit width of the waveform. This method is suitable when the baud rate deviation is large or the baud rate is uncertain. This is the self-check method that engineers are more accustomed to. To estimate the baud rate, you need to look at the minimum bit width in the waveform. From Figure 2, the time base gear is 100us, and the minimum bit width just occupies one grid. The minimum bit width is about 100us, which is equal to 10000bps after conversion. To get a more accurate baud rate value, you can use the measurement function of the oscilloscope. Open the[measure]in the oscilloscope panel, select the baud rate measurement item, and observe the comparison of the baud rate measurement results, as shown in the red box in Figure 2 below.
The example cited at the beginning is precisely because the baud rate has drifted, which is actually 10000 bps, and the decoding is set according to the normal part of 9600bps. In this calculation, the baud rate error is greater than 4%, which will cause the decoding result to be incorrect. correct. Change the crystal oscillator and decode again, the communication is normal as expected.
Figure 2 Estimate the baud rate from the minimum bit width of the waveform
Summarize
Although the baud rate is only a parameter in decoding, the influence caused by its drift cannot be ignored. It may be a factor that causes communication failures. Pay attention to check the baud rate before decoding. Such a small detail may save the time of troubleshooting in the future. Starting from the waveform, re-examine the value of the oscilloscope. It is used to observe the waveform and analyze the data to detect whether the component under test is normal.
The Links: LQ035Q7DB03R 2MBI200J-140
0 Comments for “How to troubleshoot abnormal communication problems caused by baud rate drift”