E-mail: info@hyxkiot.com Call: +86 13480952801
Your Location:Home > News > Industry News

How to Check Serial Communication Problems

Release date:2022-6-29 5:00:49

When engineers are engaged in the development of embedded-related projects, they often encounter various serial communication problems.

Serial communication refers to a communication method in which data is transmitted bit by bit between peripherals and computers, or between peripherals and peripherals through data signal lines, ground wires, etc. The communication format of this communication mode includes start bit, data bit, parity bit and stop bit, as shown in the figure below. Serial communication is characterized by low cost but slow transmission speed. The distance of serial communication can be from several meters to several kilometers.

Serial communication structure

How do we troubleshoot serial communication problems?


1. Check the middleware

Serial communication must have a sending end and a receiving end, and the two pass through the middleware (such as wires). If you encounter problems, you should first ensure that the wires are connected properly. If this part is not determined, it is likely to be useless to investigate other directions directly.

2. Troubleshoot the hardware layer

Use logic analyzers, oscilloscopes and other instruments to determine whether the pin waveforms of the transmitter and receiver are normal when they are transmitting, receiving, and idle. When the serial port is idle, it is high level, and the level changes when there is data. At the same time, it is necessary to determine whether the voltage is normal. The position of waveform measurement starts from the final point, and then checks the detection points in the middle part in turn to determine the problem location.

If you find waveform deformation, distortion, abnormal voltage, etc., please ask the hardware engineer to assist in troubleshooting. The waveform can be seen at its starting point, but not at the end point, and a multimeter is required to determine if the pins are soldered.

3. Check the serial port driver layer

If there is no waveform on the serial port on the sending end after checking that the hardware is no problem, then you need to check whether the serial port driver is configured successfully. You can first short-circuit the Tx and Rx pins of the transmitter to perform a loopback test. It is best to test with a simple routine first, trying to exclude the influence of multiple variables. It is necessary to pay special attention to the fact that you should not only look at the code logic, but also pay attention to the actual debugging, and be good at using the software debugging window to observe the values of the relevant registers.

4. Check the application protocol layer

Through the investigation in the above direction, it can be proved that there is no problem with spontaneous collection. Next, verify whether the two parties can communicate normally. Possible problems at the application protocol layer include:

a. There is a problem with the data protocol between the sender and the receiver, such as CRC, frame header and frame end check, and parsing data packets.

b. The parameters configured by the serial port of the sender and the receiver: the baud rate and the parity bit are inconsistent, resulting in the inability to communicate.

 

In addition, you should also pay attention to the following points:

a. Since the signal is easily disturbed, it is recommended to use a shielded wire, and the wiring must be strict, and the best grounding is required. For some 485 communications, it is also necessary to consider connecting a terminal resistor to match. If it is RS232 communication, try not to make the line too long.

b. Because many devices have errors in the baud rate calculated by external crystal oscillators or internal clocks. In this case, if the message is too long, errors will accumulate, and the serial port will recognize garbled characters or cannot be received.

c. In some places where there may be interference, you can consider using odd parity or even parity, which can filter out erroneous packets or try to use some data verification protocols to prevent data errors.

Copyright © 2021 Shenzhen Huayang Xinke Electronics Co., Ltd. All rights reserved