20.4.2.2 LIN/J2602

The UART provides support for the Local Interconnect Network (LIN) protocol for both Commander and Responder processes to reduce software overhead. The LIN protocol is typically used in automotive applications and packages bytes into message frames. The LIN protocol has two types of processes: Commander and Responder. A network can have only one Commander and multiple Responders. The Commander process transmits a header containing a command that the Responder(s) can respond to. The Commander process part of a LIN message frame consists of the following:

  1. Break character (11 bits minimum received, 13 transmitted)
  2. Delimiter bit
  3. Sync byte (0x55)
  4. Protected ID (PID) field

The Responder processes, then completes, the message frame by transmitting the requested data and checksum.

  1. Data (up to eight bytes)
  2. Checksum

The UART has two LIN modes, Commander/Responder and Responder Only, selected by the MODE[3:0] bits (UxCON[3:0]). The Commander/Responder mode allows a single instance of a UART to handle both Commander and Responder software processes.

A LIN frame starts with the Commander process sending a Break, followed by a Sync to allow the receiver to synchronize the baud rate to the transmitter. The PID byte follows and is used by the Responder to determine if, or how, to respond. A Responder process then responds with up to eight bytes of data and a checksum. A LIN frame is shown in Figure 20-13.

Figure 20-13. LIN Frame

The PID byte consists of six bits of data and two parity bits, P0 followed by P1. The PID value is written to Parameter 1 (P1[5:0]), and the parity bits are automatically calculated. Parameter 1 can only be written when the transmitter is Idle. The parity bits are calculated as follows:

P0 = PID[0] XOR PID[1] XOR PID[2] XOR PID[4]

P1 = NOT (PID[1] XOR PID[3] XOR PID[4] XOR PID[5])

The UART automatically calculates the checksum. Two types of LIN checksums are supported and selected by the C0EN bit (UxCON[19]). When C0EN = 0 (default), the legacy LIN checksum method is used, which uses only data bytes. When C0EN = 1, the checksum also includes the PID. The checksum is calculated by adding the number of data bytes, defined by Parameter 2, adding the carry result and finally inverting the sum.

Table 20-7 provides an example checksum calculation for a LIN frame of four data bytes in length, with data values of 0x4A, 0x55, 0x93 and 0xE5.

Table 20-7. LIN Checksum Example (C0EN = 1 or 0)
ActionHexCarryD7D6D5D4D3D2D1D0
0x4A0x4A01001010
+0x55 
Add Carry0x9F
0x9F01
10
00
01
11
11
11
11
1
+0x93 
Add Carry0x132
0x3310
00
01
11
10
00
01
10
1
+0xE5 
Add Carry0x118
0x1910
00
00
01
11
10
00
00
1
Invert0xE6(1)11100110
Receiver Verification
Check 
Local + Received0x19(2)+0xE6(1)
Note:
  1. This is the checksum value transmitted as the last byte.
  2. This is the checksum value calculated by the receiver.

For a transmit and receive operation, the calculated checksum is stored in UxCHK.