Last Time: Embedded Networks
Last Time: Embedded Networks
Embedded networks
Characteristics
Requirements
Simple embedded LANs
• Bit banged
• SPI
• I2C
• LIN
• Ethernet
Today
CAN Bus
Intro
Low-level stuff
Frame types
Arbitration
Filtering
Higher-level protocols
Motivation
Some new cars contain > 3 miles of wire
Node 2
dominant recessive
dominant dominant dominant
Node 1
recessive dominant recessive
So:
When a node transmits dominant, it always hears dominant
When a node transmits recessive and hears dominant, then
there is a bus conflict
Soon we’ll see why this is important
More Low Level
CAN Encoding: Non-return to zero (NRZ)
Lots of consecutive zeros or ones leave the bus in a single
state for a long time
In contrast, for a Manchester encoding each bit contains a
transition
NRZ problem: Not self-clocking
Nodes can easily lose bus synchronization
Solution: Bit stuffing
After transmitting 5 consecutive bits at either dominant or
recessive, transmit 1 bit of the opposite polarity
Receivers perform destuffing to get the original message back
CAN Clock Synchronization
Problem: Nodes rapidly lose sync when bus is idle
Idle bus is all recessive – no transitions
Bit stuffing only applies to messages
Solution: All nodes sync to the leading edge of the
“start of frame” bit of the first transmitter
Additionally: Nodes resynchronize on every
recessive to dominant edge
16 message buffers
Each can be used for either transmit or receive
Buffering helps tolerate bursty traffic
Transmission
Both priority order and queue order are supported
Receiving
FlexCAN unit looks for a receive buffer with matching ID
Some ID bits can be specified as don’t cares
More CAN on CF
Interrupt sources
Message buffer
• 32 possibilities – successful transmit / receive from each
of the 16 buffers
Error
Bus off – too many errors
Higher Level Standards
CAN leaves much unspecified
How to assign identifiers?
Endianness of data?
Standardized higher-level protocols built on CAN:
CANKingdom
CANOpen
DeviceNet
J1939
Smart Distributed System
Similar to how
TCP is built in IP
HTTP is built in TCP
Etc.
CANOpen
Important device types are described by device
profiles
Digital and analog I/O modules
Drives
Sensors
Etc.
Profiles describe how to access data, parameters,
etc.
CAN Summary
Not the cheapest network
E.g., LIN bus is cheaper
Not suitable for high-bandwidth applications
E.g. in-car entertainment – streaming audio and video
MOST – Media Oriented Systems Transport
Design point:
Used where reliable, timely, medium-bandwidth
communication is needed
Real-time control of engine and other major car systems