LIN-Telegram Structure


Protocol specification (Message Frame)

(1) The byte interval is located between each byte;

(2) The response interval is located between the header and the response;

(3) Leave sufficient processing time for the MCU;

(4) The frame length may increase;

A complete LIN bus message frame "Message Frame" includes the header "Header" and the response "Response". The master task is responsible for sending the frame header; the slave task receives the frame header and parses the information contained in the frame header, and then decides whether to send a response, receive a response, or not make any response.
LIN1


1. Byte field

1) SCI-based communication format;

2) The length of each byte field is timed by 10 timing bits (BIT TIME);
byte field
①Start bit (START BIT) is a "dominant" bit, which marks the beginning of the byte;
②8 is the data bit, and the lowest bit is sent first;
③Stop bit (STOP BIST) is a "recessive" bit, marking the end of the byte field.

2. Header Field

header

Synchronization break

The sync interval segment is composed of a sync interval (Break) and a sync interval segment delimiter (Break Delimiter).

Function: To identify the beginning of the message, sent by the master node; to make all slave tasks synchronize with the bus clock signal.
The interval signal consists of at least 13 dominant bits followed by an interval delimiter of at least 1 recessive bit;
interval field

The role of the interval delimiter: used to detect the start bit of the next synchronization field (Synch Field).

Sync segment (SyncByte FIELD)

1) Ensure that all slave nodes use the same baud rate as the node to send and receive data;

2) One byte, fixed structure: 0X55;
synchronous field

Protected ID field (Protected Identifier Field)

The first 6 bits of the protected ID segment are called the frame ID (Frame ID), plus two parity bits are called the protected ID.
1) ID ranges from 0 to 63 (0x3f);
2) Parity (Parity) P0, P1;
identifier field
ID4 and ID5 define the data length of the data field.
If necessary (for example, compatible with LIN specification 1.1), the identifier bits ID4 and ID5 can define the number of NDATA data fields in the message (see the table below). This divides the set of 64 identifiers into 4 subsets of 16 identifiers with 2, 4 and 8 data fields respectively.

ID5 ID4 Number of data fields
0 0 2
0 1 2
1 0 4
1 1 8
【LIN2.0相对于LIN1.3最主要的差别】
1、支持最多8个字节的数据序列;
2、取消了受保护标识符中的数据长度字段,即传输长度不再受限于ID,并将最后一个字节视为校验和;
3、校验和的验算包括了受保护标识符。
4、支持自动波特率检测功能;
5、对偶发帧进行了定义;
6、网络管理的定时用秒来定义,而不是用比特数来定义;

②Parity bit P0 P1 (⊕XOR operation)
Parity

3. Data Field

1) The length of the data field is 1 to 8 bytes;

2) The low byte is sent first, and the low byte is sent first;

3) If the length of a certain signal exceeds 1 byte, it is sent with the low bit first (little endian);
data field

4. Checksum Field

Used to verify whether the received data is correct

1) Classic Checksum only checks the data field (LIN1.3)

2) Enhance Checksum (Enhance Checksum) check identifier field and data field content (LIN2.0, LIN2.1)

Before LIN2.0 LIN2.0 and later
communication frame classic Enhanced
diagnostic frame classic classic

Frames with identifiers 0x3C and 0x3D can only use the classic checksum

checksum field
Algorithm (Classical): Accumulate all bytes. To judge each addition, if the sum is greater than 0xFF, then add the 1 of the upper eight bits to the lower eight bits, which is actually adding 1 to the lower eight bits (reversing the eight-bit sum). After getting the final result, take its inverse, and we get the final checksum.
For example: using standard checksum, Data1 = 0x4A, Data2 = 0x55, Data3 = 0x93, Data4 = 0xE5
check
Explain the above figure, 0x4A+0x55 = 0x9F is no doubt, plus 0x93 = 0x132, obviously, it exceeds 0xFF, decomposed into 0x1 and 0x32, the outstanding high 8 bits are deleted, added to the low 8 bits, 0x1+0x3 2=0x33. Add 0xE5 = 0x118, which is beyond, 0x1+0x18=0x19. Negate (Not), 0xE6.

Guess you like

Origin blog.csdn.net/qq_41908302/article/details/130796111