Issue
150 January 2003
Going
Mobile
FRAME
UP
With
the previous explanation in mind, understanding the
LIN message structure is a snap (see Figure 2). The
action starts when the master issues a sync break, driving
the bus low for 13 bit times. This is the single area
where LIN is a little fussy about UARTs. Those who don’t
have hardware break generation and detection will have
to use an interrupt and/or I/O line. Of course, the
same goes for bit-banged implementations, which are
feasible thanks to the relatively low speed and complexity
involved.
|

(Click
here to enlarge)
|
Figure
2—In LIN, the master always initiates communication
with a sync break, sync byte, and identifier. Subsequently,
a slave (possibly including the master) issues a
response (1, 2, or 4 bytes of data) and checksum. |
Following
the break, the master issues a sync byte, 0x55. Slaves
use the alternating ones and zeroes to align with the
master’s time base. This is a key feature that allows
LIN devices to get by with relatively sloppy (i.e.,
±15%) on-board (typically RC) clocks. Of course, if
both the master and slave utilize accurate clocks (e.g.,
crystal), the entire issue can be ignored.
Finally,
the master issues the aforementioned identifier byte
comprised of a 4-bit ID code, 2-bit length field, and
even and odd parity bits. At this point, all slaves
have detected the sync break and established proper
timing. After receiving the identifier byte, the appropriate
slave responds with 2, 4, or 8 bytes of data (depending
on the length field in the identifier byte) and a checksum.
Thankfully, there are no rigid response time specs,
making life easy for everyone. The only restriction
is that the overall response must arrive within the
maximum time allowed for a single message in order to
allow a loss of communication to be detected.
Of
the 64 unique identifiers that are available (i.e.,
combined 4-bit ID and 2-bit length), four are reserved
by LIN for administration (e.g., upload and download
firmware) and future extensions. One of the administrative
commands the master can issue is Sleep, which tells
all of the nodes that they can ignore the LIN bus until
further notice.
Said
notice comes in the form of a bus wake-up signal, which
is like a Sync Break (nominally eight bit times versus
the latter’s 13), except that the slave issues it. The
wake-up signal tells the master to start polling and
alerts other slaves to get ready for LIN bus action
(i.e., the forthcoming sync break issued by the newly
woken master).
Yes,
the master doesn’t know which slave issued the wake-up
call, and the service time will be determined by that
slave’s place in the polling pecking order; however,
at least that service time is completely predictable
because, like all other LIN timing, it’s totally under
the master’s control.
The
bottom line is that every time you’re about to raise
an objection and say, "But…," just remember
we’re talking about switches, lights, motors, and humans
(i.e., a timescale that even the slowest incarnations
of LIN can manage).