|
by Tom Cantrell
Start ı Little
Network ı Mini-Message ı LO
BAT ı Caravan ı Sources
and PDF
MINI-MESSAGE
Letıs look at the overall way a LIN setup
works. As shown in Figure 3, the basic unit of activity is a message
frame. The master initiates a message transfer by issuing a header
that consists of three parts.
 |
Figure 3ıThe master issues
the header, and the appropriate responder (i.e., the master
or a particular slave) gives back the data in due course. (enlarge) |
First, the master holds the bus low for
at least 13-bit times to get all the slave nodesı attention with the
SYNCH BREAK. At the end of the SYNCH BREAK, the master
sends the character 0x55, which (with alternating ones and zeros)
acts as a SYNCH FIELD. Each node times the bit transitions
in the SYNCH FIELD to adjust their own data rate. With everything
in sync, the master sends the IDENT field, which includes a
4-bit identifier, a 2-bit designator that specifies the amount of
data to transfer (1, 2, or 4 bytes), and two parity bits. The parity
scheme seems like a bit of a head-scratcher but, besides simply checking
the integrity of the IDENT field, also ensures that patterns
0x00 and 0xFF never appear on the bus.
At this point, the master has requested
the appearance of a particular data item defined by the 4-bit identifier
and length (1-, 2-, or 4-byte) designator. Now, a responder puts the
data on the bus, protected by a simple checksum rather than a complicated
CRC.
Typically, a slave node provides the
response. However, itıs important to understand that the response
isnıt to the master, but to the bus. In fact, the master may supply
the data in response to its own header, which allows it to send its
own data on the bus. Furthermore, everything on the bus, the master
and all slaves, has the opportunity to look at the response. For example,
a door lock solenoid and window motor could both go into action upon
detecting a door key lock/unlock message.
How does LIN deal with the possibility
of collision? It doesnıt. The protocol dictates only a single responder.
Each node is required to monitor its own output in order to detect
and log the occurrence of a collision, but thatıs it. Thereıs no collision
recovery (i.e., arbitration) mechanism built-in because that would
compromise timing predictability. Of course, the master can request
collision and other error-status reports (parity, checksum, or no
response) from time to time if desired. Otherwise, the strategy is
basically to try again next time (i.e., bad messages are just thrown
away), which is arguably the best course of action when dealing with
lights, switches, and such.
Notice that the spec doesnıt limit the
time allowed between the header and data or between each data byte.
Instead, it simply dictates a maximum length for the entire message
frame. Thatıs nice because it means even a slow micro can handle the
protocol, yet the overall message timing remains bounded.
PREVIOUS
NEXT
Circuit Cellar
provides up-to-date information for engineers. Visit www.circuitcellar.com
for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe
online. ıCircuit Cellar, the Magazine for Computer Applications.
Posted with permission.
|