Serial Port Waveform Analysis

 

  1. Format of serial data

The general format of asynchronous serial data is: start bit + data bit + stop bit, where the start bit is 1 bit, the data bit can be 5, 6, 7, and 8 bits, and the stop bit can be 1, 1.5, and 2 bits.

The start bit is a bit with a value of 0, so for a positive logic TTL level, the start bit is a low level for one bit time; the stop bit is a bit with a value of 1, so for a positive logic TTL level, The stop bit is high. The opposite is true for negative logic (eg RS-232 levels).

For example, for the data transmission waveform of hexadecimal data 0X5A, the data format is, baud rate: 115200, data bits: 8, stop bit 1, parity: none. Its waveform on the signal line is shown in the figure below.

 

2.      7 -bit data transfer

General data transmission will be defined as 8-bit format, and some special fields will use the format of data bits as 5, 6, 7, bits;

For example, some plc devices will use a 5-bit data format, and for example, the standard format of marine electronic equipment (NMEA-0183 protocol) has 6 bits of data; although the actual data used for display will be synthesized into 8 bits, they The data format of 5, 6, and 7 is used during data transmission;

    We analyze from the waveform, what is the format of the data transmission of the special bits; when the data bits are not 8 bits, the data will be lost from the high bits, such as the 5-bit data format, the top 3 bits will be lost, and the maximum data can only be _ _ _1 1111; 6-bit data format, _ _ 11 1111; 7-bit data _111 1111; high bits are lost, and the lost data is regarded as 0 by default; therefore, the maximum number of 5-bit data is 0001 1111 (0x1f), 6-bit data 0011 1111 ( 0x3f), 7-bit data 0111 1111 (0x7f); use 7-bit data to capture a wave, give a chestnut;

 

A complete frame of data is 0 0101 101_ 1 with one head and one tail indicating the start and end, which is not used for data; 0101 101_ is the real data; the lost data is filled with zeros and synthesized 0101 1010, then the data is 0x5a; pay attention to the high bit first, low position behind;

 

Let's change the data to do the test;

For example, use 0XCA; send to the serial port, the data becomes 0x4A;

 

The waveform is as shown below

 3.      6 -bit data transfer

6-bit data transmission, lose the upper 2 bits; for example, transmit 0xCA; after data transmission, get 0x0A

 

Change the data to test 0X5A; after the data is sent, the received data is 0x1A;

 

The general serial port assistant can only receive 7-bit and 8-bit data. When it is configured to receive 5 or 6-bit data, the software opens an error, as shown in the figure below; later I wrote a serial port assistant myself, when the data bits are configured as 5 and 6 bits are also wrong; I don't know if Microsoft does not support it;

4.      5 -bit data transfer

5-bit data transmission, lose the upper 3 bits; for example, transmit 0x5A; after data transmission, get 0x1A

 

Change the data to test 0X3c; after the data is sent, the received data is 0x1c;

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324780352&siteId=291194637