Many mechanical components in the automotive sector have been replaced or are now being
replaced by intelligent mechatronical systems. A lot of wires are needed to connect these
compone nts. To red uce the amount of wires an d to hand le commu nicati ons betwee n thes e
systems, many car m anufacturer s have created different bus syst ems that are incom patible
with each other.
In order to have a standard sub-bus, car manufacturers in Europe have formed a consortium
to define a new communications standard for the automotive sector. T he new bus, called LIN
bus, was invented to be used in sim ple switchin g applications like c ar seats, d oor loc ks, sun
roofs, rain sensors, mirrors and so on.
The LIN bus is a sub-bus system based on a serial communications protocol. The bus is a
single master / multiple slave bus that uses a single wire to transmit data.
To reduce costs, components can be driven without crystal or ceramic resonators. Time synchronization permits the correct transmission and reception of data. The system is based on a
UART / SCI hardware interface that is common to most microcontrollers.
The bus detects defective nodes in the ne twork. Data chec ksum and pa rity check guarantee
safety and error detection.
As a long-standing partner to the automoti ve industry, STMicroele ctronics offers a comple te
range of LIN silicon products: slave and master LIN micro controllers covering the p rotocol
handler part and LIN transceivers for the physical line interface. For a quick start w ith LIN,
STMicroelectronics supports you with LIN software enabling you to rapidly set up your first LIN
communication and focus on your specific application requirements.
The aim of this chapter is to give an overview of the LIN pr otocol and concept. For detail ed and
up-to-date information please ref er to the official LIN hom epage : www.lin-subbus.org where
you can register for the LIN specification package.
The LIN specification package consists of three parts:
■ The LIN protocol specification
■ The LIN configuration language description
■ The LIN API
The first part describes the LIN physical and data link layers. The second part describes the
LIN configuration language. The LIN configuration language enables the user LIN network to
be described in a file (how many nodes, how many frames, frame description, baudrate etc.).
The goal of t his spec ification is t o ea se comm unications be tween the p arties inv olved in the
development of a LIN ne twork like c ar m anu factur ers and the ir suppl iers. The th ird an d l ast
part is abo ut t he sof twa re impl em en tati on of the L IN pro toco l a nd spe cif ies som e po ints on
how the software implementation has to be done.
The LIN concept uses a single master / multiple slave model. Only the master is able to initiate
a communication. A LIN frame consists of a header and a response par t. To init iate a c ommunication with a slave the master sends the header part. If the master wants to send data to the
slave it goes on sending the response part. If the master re quests data from the slave the
slave sends the response part.
Figure 2. Basics of LIN communicatio n
Master to slave 1
Slave 1
Slave 2
Master
Slave 2 to master
sent by:
LIN
Bus
Master
Slave 1
1 LIN frame
HeaderResponse
Slave 2
Direct com mu ni cat ion b et wee n sl aves is n ot pos si ble . B ut a s al l n ode s a l way s li sten t o the
bus, a master request can be used to handle slave-to-slave communications.
4/44
LIN (LOCAL INTERCONNECT NE TWORK) SOLUTIONS
The LIN protocol is object-oriented and not address-oriented. The header contains the identifier which ident ifies the LI N f rame and t he data i t c onta ins. Diffe rent no des m ay r ecei ve t he
same frame data.
The response part consists mainly of data of selectable length (1 to 8 bytes). The data are secured by an 8 bit checksum.
The LIN protocol is time-trigger oriented. The master periodically sends the same sequence of
LIN fram es. Each s equ ence , the m ast er an d the slav es upd ate t he da ta th ey se nd an d receive. The sequence sent by the master may change depending on application events.
Example: The slave is a sensor measuring a analog value which is communicated to the
master via LIN. The slave continuously measures its analog input independently from the LIN
communication. In response to a m aster req uest (periodical) the slave sends the u p-to-date/
last measured value of the analog input.
Figure 3. Time-triggered protocol
Master
Slave 1
Slave 2
Analog
value
1 sequence
change
LIN
Bus
25
Analog value:25
25
3838
Analog value:38
In order to achieve a good level of security, different mechani sms exist like parity bits on the
identifier or checksum on data bytes.
One important feature of the protocol is to enable the slave MCUs to run with low cost oscillators such as an integrated RC oscillator provided that the accuracy is better than +/-15%. For
this purpose the header contains a sync field byte c onsisting of the constant 0x55. This byte
enables each slave to measure the master bit time and to synchronize its clock accordingly.
In order to obtain very low power consumption, the master is able to send a sleep frame. Any
node can go into low power mode. To wake up the network, any node can send a so-called
wake-up signal.
5/44
LIN (LOCAL INTERCONNECT NETWORK) SOLUTIONS
Figure 4. Sleep mode - wake-up
Sleep mode
command
“normal” modeSleep mode
Wake-up
signal
Network
start-up
“normal“
mode
6/44
LIN (LOCAL INTERCONNECT NE TWORK) SOLUTIONS
2 LIN PRODUCTS
A typical LIN node consists of a microcontroller for handling the LIN protocol and a LIN transceiver for interfacing the digital part and the physical line (see Figure 5 . LIN bus topo logy ).
STMicroelectronics offers both kind of products.
Figure 5. LIN bus topo logy
LIN Bus
TRANSCEIVER
MASTER
LIN Bus
RXTX
MICROCONTROLLER
SLAVE
SLAVE
SLAVE
2.1 LIN MICROCONTROLLERS
STMicroelectronics offers a wide range of microcontrollers suitable for master and/or slave
nodes.
2.1.1 LIN Slave MCUs
Table 1. Very low cost LIN slave MCUs - full software solution - Flash/ROM MCUs
Serial Interface2 SCI, SPI, I²C1/2 SCI, SPI, I²C
ADC16 x 10 bits8/16 x 10 bits
Network Interface2 CAN, J1850CAN, J1850J1850Temp. Range-40°C to 125°C or -40°C to 85°C
PackageP/TQFP100P / TQ FP100 and TQ FP64
Note: The master MCUs listed abov e have all an on-chip CAN peripher al. This corresponds to
the initi al LIN conc ept: t he LI N netw ork a s sub- netw ork of CAN . How eve r any ot her M CUs
(listed above as slave for example) can be used to implement a master node.
2.2 LIN TRANSCEIVER S
To ensure the physical behaviour of the LIN bus STMicroelectronics also offers K-Line dr ivers
and a dedicated LIN Bus Transceiver.
2.2.1 L9637 K-Line Transceiver
The L9637 K-Line transceiver is a monolithic integrated circuit containing standard ISO 9141
compatible interface functions. Its features are listed below.
■ Operating power supply voltage range 4.5V ≤V
■ Reverse supply battery protected down to V
■ Stand-by mode with very low current consumption IS
■ Low quiescent current in OFF condition IS
■ TTL compatible TX input
■ Bidirectional K-I/O pin with supply voltage dependent input threshold
■ Overtemperature shut down function selec tive to K-I/O pin
■ Wide input and output voltage range -24V ≤V
■ K output current limitation, typical I
■ Defined OFF output status in under voltage condition and V
■ Controlled output slope for low EMI
= 60mA
K
OFF
≤36V (40V for transients )
S
≥-24V
S
1µA @Vcc 0.5V
SB
= 120µA
≤V
K
S
or GND interruption
S
■ High input impedance for open V
■ Defined output on status of LO or RX for open LI or K inputs
■ Defined K output off for TX input open
or GND connection
S
9/44
LIN (LOCAL INTERCONNECT NETWORK) SOLUTIONS
■ Integrated pull up resistors for TX, RX and LO
■ EMI robustness optimized
2.2.2 L9638 LIN Transceiver
The L9638 LIN transceiver is a monolithic integrated circuit fulfilling the LIN specification.
Its features are listed below.
■ Wake up capability by:
- LIN bus
- External signal (edge triggered)
■ System wake up functions:
- Inhibit output
- RxD output
■ Quiescent current less than 25µA
■ Fail safe functions implemented
■ Pin compatible to L9637
Figure 6. L9638 block diagram
V
S
Int.5V
RXD
T
D
X
EN
WUP
Glitch
Filter
Internal
Voltage
Regulator
Glitch
Filter
Control
Logic
Protection
LIN
INH
10/44
GND
LIN (LOCAL INTERCONNECT NE TWORK) SOLUTIONS
The following figure (Fig ure 7) shows a t ypical applic ation of the L9 638 L IN tran sceiv er together with the ST72124J microcontroller and a voltage regulator.
Figure 7. Application of L9638 with ST72124J Microcontroller
LIN Node
GND
Vbatt
voltage
Vs
regulator
EN
Vout
RES
GND
Vdd
reset
ST72124J
MCU
Vs
INH
EN
I/O pin
LIN
LIN
LIN
Vdd
transceiver
L9638
WUP
TxD
RxD
TDI
RDO
GND
The voltage regulator supplies the application an d generates the MCU reset signal. The LIN
transcei ver is th e physic al line inte rface betw een the SC I (Seria l Com munic ation In terfac e)
TDI and RDO pins of the microcontroller and the LIN bus line. The microcontroller handles the
LIN protocol and the application functions.
In order to lower power co nsumption the microco ntroller is able t o switch o ff the LIN transceiver via the L9638 “EN” input. The transceiver i s then abl e to switch off the voltage regulator
by connecting its “INH” output to the “EN” i nput of the v oltage regulator. In this s tate any activity on the LIN bus wi ll cause the L9638 to wake the voltage r egulator up v ia the “INH” p in.
Another wake-up source is the “W UP” pin of the L9638 that can be used for contact sens ing.
Any edge on this pin will also wake up the regulator.
11/44
LIN (LOCAL INTERCONNECT NETWORK) SOLUTIONS
3 LIN SOFTW ARE
Table 6. Software Overview
Version2.0
Support ed nodesslave
Supported MCUsall ST 7 MC U s
LIN protocol specification revisionrev 1.2
The LIN standard includes the specification of the communication protocol but also the use of
associated tools.
STMicroelectronics supp orts the deve lopm ent of y our L IN app lication by prov iding re ady-touse LIN software. This software only handles the communication protocol part. For a complete
software development t ool solution y ou can con tact LIN s pecialist t hird p arty tools ma nufac turers like VCT (http://www.vct.se) or Vector (http://www.vector-informatik.de).
The software supports LIN slave nodes. It consists of 4 files:
– lin.c/h: protocol handler code
– lin_config.c: LIN parameter configuration file
– lin_ai.c: application interface
A fifth additional file is delivered:
– lib.h: library file (macros, types definition)
The software supports the COSMIC C comp iler.
Figure 8. Software Architecture
application
APPLICATION
specif ics
lin.c
lin_config.h
lin-ai.c
LIN
MESSAGE
interrupt
12/44
HARDWARE
LIN (LOCAL INTERCONNECT NE TWORK) SOLUTIONS
The software is interrupt driven. As soon as a message begins on the bus, an inter rupt is generated and automatically handles the protocol. T his m eans that the protocol handler is totally
autonomous. It runs in the background. When the received frame is decoded by the software
this is notified to the application in the lin_ai.c. In this file the user is able to customize the behaviour of the application upon reception of a frame for example.
3.1 TYPES AND MACRO DEFINITIONS: LIB.H
3.1.1 Debug settings
see 4.4.1 Timing considerations
3.1.2 Types
The software uses predefined types for 1-byte and 2-byte variables.
The name used for the one-byte type is “uByte“.
The name used the two-byte type is “uWord”.
Beside these, a third type is used to define two-byte variables that can also be accessed high
byte or low byte only.
typedef union {
unsigned int w_form;
struct {
unsigned char high, low;
} b_form;
} TwoBytes;
These types are defined in the lib.h file.
3.1.3 Macros
Three macros for register bit access are defined:
– SetBit(var,pos): Set bit “pos” of “var” variable
– ClrBit(var,pos): Clear bit “pos” of “var” variable
– ValBit(var,pos): Test bit “pos” of “var” variable. Return “0” if reset another value otherwise.
3.2 PROTOCOL HANDLER: LIN.P/H
The lin.p file contains the protocol handler. The user has no access to this file. It should simply
be linked to the rest of the application. The lin.p file is encrypted and can therefore not be read
but must be compiled and linked to the rest of the application.
The lin.h con tains th e definition of new typ es and th e protot ypes of th e functions defined in
lin.c.