Download AN2599/D - NXP Semiconductors

Transcript
Freescale Semiconductor, Inc.
AN2599/D
LIN Communication
LIN Communication
Freescale Semiconductor, Inc...
LIN information is sent on the LIN bus in the form of message frames. Message
frames can be of selectable length, but they always have the same format. A
message frame has from 0 to 8 bytes of data in addition to the 3 bytes of control
and data security information.
Each message frame starts with the master sending out a synchronization
break signal (synchbreak field), followed by a synchronization field and a
message identifier field. The slave then responds with the data field (which can
be from 0 to 8 bytes) and then the checksum field. The synchbreak field
identifies the beginning of a new message frame and provides a regular
opportunity for the slave to synchronize on the bus clock. The synch field
contains the information for the clock synchronization and is always 0x55.
An acknowledgment procedure for a correctly received LIN message is not
defined in the LIN protocol.
MESSAGE FRAME
HEADER
SYNCH
BREAK
SYNCH
FIELD
INTER-FRAME
SPACE
OR BREAK
RESPONSE
IDENT
FIELD
DATA
FIELD
DATA
FIELD
DATA
FIELD
IN-FRAME
RESPONSE SPACE
DATA CHECKSUM
FIELD
FIELD
INTER-BYTE
SPACE
Figure 3. LIN Message Frame
Driver Software
Overview
The file LINdriver.c contains the main functionality for running the driver. All
LIN communication activities are handled in the timer channel 1 ISR
(TimA1ISR). Timer channel 1 is configured for input capture, so when activity
on the LIN bus is detected, there is an interrupt and TimA1ISR is entered.
In TimA1ISR, the driver goes through several states. The flow of these states
is described in TimA1ISR States and illustrated in Figure 4.
1.
2.
3.
4.
5.
6.
7.
Unsynchronized
Idle
PossibleSync
SyncBreak
Synchronized
ReceiveID
Either
a. ReceivingWFS then Receiving OR
b. Sending
Generic LIN Driver for MC68HC908QY4
For More Information On This Product,
Go to: www.freescale.com
7