Professional Documents
Culture Documents
Page 1
How it all began...
Air
Engine Anti- Lighting Con-
Control Lock dition Power
Brakes Locks
Dash-
board
Airbag
Power
Trans- Active Seats
mission Suspen- Power
Control sion Win-
dows
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 2
Page 2
How it all began (cont.)
Air
Engine Anti- Lighting Con-
Control Lock dition Power
Brakes Locks
Dash-
board
Airbag
Power
Trans- Active Seats
mission Suspen- Power
Control sion Win-
dows
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 3
Page 3
How it all began (cont.)
Air
Engine Anti- Lighting Con-
Control Lock dition Power
Brakes CAN Locks
CAN CAN CAN
CAN
High Speed Dash- Low Speed
CAN
CAN
board
CAN
CAN
Airbag
CAN CAN Power
Seats CAN
Trans- Active
mission Suspen- Power
Control sion Win-
dows
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 4
The solution to this problem was the connection of the control systems
via a serial bus system. This bus had to fulfill some special
requirements due to its usage in a vehicle.
With the use of CAN, point-to-point wiring is replaced by one serial bus
connecting all control systems. This is accomplished by adding some
CAN-specific hardware to each control unit that provides the "rules" or
the protocol for transmitting and receiving information via the bus.
Page 4
Overview
80
CAN
}
60
Nodes
1997
1998
1999
2000
1 Physical Layer
Page 5
Basic Concepts
n Multimaster n Easy
CAN
Concept connection/
Nodes
disconnection
n Number of of nodes
nodes Node A Node n
not limited by e.g. e.g. n Broadcast/
protocol ABS EMS Multicast
capability
n No node
addressing,
Message
identifier CAN-Bus
specifies (logical)
contents &
priority
CAN is a multi-master bus with an open, linear structure with one logic
bus line and equal nodes. The number of nodes is not limited by the
protocol.
In the CAN protocol, the bus nodes do not have a specific address.
Instead, the address information is contained in the identifiers of the
transmitted messages, indicating the message content and the priority
of the message.
The number of nodes may be changed dynamically without disturbing
the communication of the other nodes.
Multicasting and Broadcasting is supported by CAN.
Page 6
Basic Concepts (cont.)
Node A Node n
n Sophisti-
e.g. ABS e.g. EMS cated Error
Application
Detection /
e.g. Handling
e.g.
Host-Controller 80C166 C167CR
n NRZ Code
or C515C
+ Bit Stuffing
CAN-Controller 81C9x CAN for
Synchroni-
CAN-Transceiver zation
Page 7
Basic Concepts -
CAN Bus Characteristics - Wired-AND
A B C BUS
D D D D
As soon as one node nodes transmits
D D R D
a dominant bit (zero):
D R D D
Bus is in the dominant state.
D R R D
R D D D
R D R D
Only if all nodes transmit
R R D D
recessive bits (ones):
R R R R
Bus is in the recessive state.
Page 8
Basic Concepts -
CAN Bus Characteristics - Wired-AND (cont.)
5V
CAN-Bus
L L L
(single logical
bus line)
R T R T R T
recessive
recessive
recessive
Node A Node B Node C
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 9
Only if all nodes transmit recessive bits (ones), the Bus is in the
recessive state.
Page 9
Basic Concepts -
CAN Bus Characteristics - Wired-AND (cont.)
5V
CAN-Bus
H L L
(single logical
bus line)
R T R T R T
recessive
recessive
dominant
As soon as one node transmits a dominant bit (zero), the bus is in the
dominant state.
Page 10
Bus Access and Arbitration: CSMA/CD w/ AMP
Node X
Node A
Node B
Node C
Inter-
Overload frame
Frame Space
These are the existing Frame formats which are now discussed in the
following slides.
Page 12
Frame Formats - Data Frame
Page 14
Frame Formats - Remote Frame (cont.)
Page 15
Frame Formats - Error Frame
An Error Frame is generated by any node that detects a bus error. The Error
Frame consists of 2 fields, an Error Flag field followed by an Error Delimiter
field. The Error Delimiter consists of 8 recessive bits and allows the bus nodes
to restart bus communications cleanly after an error. There are, however, two
forms of Error Flag fields. The form of the Error Flag field depends on the
error statusof the node that detects the error.
If an error-active node detects a bus error then the node interrupts
transmission of the current message by generating an active error flag. The
active error flag is composed of six consecutive dominant bits. This bit
sequence actively violates the bit stuffing rule. All other stations recognize the
resulting bit stuffing error and in turn generate Error Frames themselves. The
Error Flag field therefore consists of between six and twelve consecutive
dominant bits (generated by one or more nodes). The Error Delimiter field
completes the Error Frame. After completion of the Error Frame bus activity
returns to normal and the interrupted node attempts to resend the aborted
message.
If an error passive node detects a bus error then the node transmits an
passive Error Flag followed, again, by the Error Delimiter field. The passive
Error Flag consists of six consecutive recessive bits, and therefore the Error
Frame (for an error passive node) consists of 14 recessive bits (i.e. no
dominant bits). From this it follows that, unless the bus error is detected by the
node that is actually transmitting (i.e. is the bus master), the transmission of an
Error Frame by an error passive node will not affect any other node on the
network. If the bus master node generates an error passive flag then this
may cause other nodes to generate error frames due to the resulting bit
stuffing violation.
Page 16
Frame Formats - Overload Frame
Page 17
Frame Formats - Interframe Space
Page 18
Error Detection - Overview
q Detected Errors:
ACK Bit
Error Error
Page 19
Error Detection - Cyclic Redundancy Check
Node A Node B
Calculated Calculated
Idle CRC Checksum: CRC Checksum: Idle
Receive 1234h 1234h Receive
Transmit Transmit
Transmitted Received
CRC Checksum: CRC Checksum:
1234h 1234h match
CAN_L
CRC Sequence
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 20
Page 20
Error Detection - Cyclic Redundancy Check (cont.)
Node A Node B
Calculated Calculated
Idle CRC Checksum: CRC Checksum: Idle
Receive 1234h 1235h Receive
Transmit Transmit
Transmitted Received
CRC Checksum: CRC Checksum:
1234h 1234h mismatch
CAN_H Error Frame
CAN_L
Page 21
Error Detection - Acknowledge
Ack. Delimiter
Acknowledge Slot
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 22
Page 22
Error Detection - Frame Check
q No dominant
bits allowed in
CRC Delimiter,
ACK Delimiter,
End of Frame,
1 1 7 3 Intermission
(Form Error)
CRC Delimiter,
Acknowledge Delimiter,
End of Frame or
Interframe Space
then a Form Error has occurred and an Error Frame is generated. The
message will then be repeated.
Page 23
Error Detection - Bit Monitoring
sends a dominant bit but detects a recessive bit on the bus line or,
sends a recessive bit but detects a dominant bit on the bus line.
Page 24
Error Detection - Bit Stuffing Check
q 6 consecutive
bits with same
polarity are not
allowed between
Start Of Frame
and CRC
Delimiter
(otherwise Bit
Stuffing Error)
If six consecutive bits with the same polarity are detected between
Start of Frame and the CRC Delimiter, the bit stuffing rule has been
violated.
A stuff error occurs and an Error Frame is generated. The message is
then repeated.
Page 25
Error Handling
CAN_L
Detected errors are made public to all other nodes via Error Frames.
The transmission of the erroneous message is aborted and the frame
is repeated as soon as possible.
Page 26
Error Handling (cont.)
REC<=127 REC>127
and or TEC>255
TEC<=127 TEC>127
Re-Initialization only
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 27
Each CAN node is in one of three error states "error active", "error passive" or
"bus off" according to the value of their internal error counters.
The error-active state is the usual state after reset. The bus node can then
receive and transmit messages and transmit active Error Frames (made of
dominant bits) without any restrictions. During CAN communication, the error
counters are updated according to quite complex rules. For each error on
reception or transmission, the error counters are incremented by a certain
value. For each successful transaction, the error counters are decremented by
a certain value. The error active state is valid as long as both error counters
are smaller than or equal to 127.
If either the receive or the transmit error counter has reached the value of
128, the node switches to the error-passive state. In the error-passive state,
messages can still be received and transmitted, although, after transmission of
a message the node must suspend transmission. It must wait 8 bit times
longer than error-active nodes before it may transmit another message. In
terms of error signaling, only passive Error Frames (made of recessive bits)
may be transmitted by an error-passive node.
If both error counters go below 128 again due to successful bus
communication, the node switches back to the error-active state.
One feature of the CAN protocol is that faulty nodes withdraw from the bus
automatically. The bus-off state is entered if the transmit error counter
exceeds the value of 255. All bus activities are stopped which makes it
temporarily impossible for the station to participate in the bus communication.
During this state, messages can be neither received nor transmitted. To return
to the error active state and to reset the error counter values, the CAN node
has to be reinitialized.
Page 27
Undetected Errors - an example
q 2000 h/year
q 500 kbps
q 25% bus load
q 1 undetected error
every 1000 years
Page 28
CAN Protocol Versions
The original CAN specifications (Versions 1.0, 1.2 and 2.0A) specify an
11 bit message identifier. This is known as "Standard CAN".
Those Data Frames and Remote Frames, which contain an 11-bit
identifier are therefore called Standard Frames.
With these frames, 211 (=2048) different messages can be identified
(identifiers 0-2047).
However, the 16 messages with the lowest priority (2032-2047) are
reserved.
Specification V2.0A has since been updated (to version 2.0B) to
remove this possible message number limitation and meet the SAE
J1939 standard for the use of CAN in trucks.
Version 2.0B CAN is referred to as "Extended CAN".
Extended Frames, according to CAN specification V2.0 part B, contain
a 29-bit identifier which allows 229 (over 536 Million) message
identifiers.
The 29-bit identifier is made up of the 11-bit identifier ("Base ID") and
the 18-bit Extended Identifier ("ID Extension").
CAN specification Version 2.0B still allows message identifier lengths
of 11 bits to be used.
Page 29
CAN Protocol Versions (cont.)
V2.0B Active
CAN Module
V2.0B Passive
CAN Module
V2.0A CAN
Module
Page 30
CAN Protocol Versions (cont.)
V2.0B Active
Tx/Rx OK Tx/Rx OK
CAN Module
V2.0B Passive
Tx/Rx OK Tolerated
CAN Module
V2.0A CAN
Tx/Rx OK Bus ERROR
Module
CAN modules specified after CAN V2.0 part A are only able to transmit
and receive Standard Frames according to the Standard CAN protocol.
Messages using the 29-bit identifier sent to a Standard CAN module
cause errors.
If a device is specified after CAN V2.0 part B, there's one more
distinction. Modules named "V2.0B Passive" can only transmit and
receive Standard Frames but tolerate Extended Frames without
generating Error Frames.
"V2.0B Active" devices are able to transmit and receive both Standard
and Extended Frames.
Siemens offers V2.0B Active and V2.0B Passive devices.
Page 31
Message Coding
Signal to Signal to
transmit a 0 transmit a 1
HIGH HIGH
LOW LOW
1
0
0 1 0 ...
Page 32
Bit Stuffing
1 2 3 4 5 67 8 ... 1 2 3 4 5 67 8 ...
data stream
No. of
consecutive
bits with
Stuff Stuff Stuff
same polarity
Bit Bit Bit
bit stream
1 1 1 2 3 4 5 1 2 3...
12345 12345 1
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 33
Page 33
Bus Synchronization
Page 34
Bit Construction
CAN frame
1 Bit Time
1 2 3 4
1 Time
Quantum
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 35
One CAN bit time (or one high or low pulse of the NRZ code) is
specified as four non-overlapping time segments.
Each segment is constructed from an integer multiple of the Time
Quantum.
The Time Quantum or TQ is the smallest discrete timing resolution
used by a CAN node.
Its length is generated by a programmable divide of the CAN node's
oscillator frequency.
There is a minimum of 8 and a maximum of 25 Time Quanta per bit.
The bit time, and therefore the bit rate, is selected by programming the
width of the Time Quantum and the number of Time Quanta in the
various segments.
Page 35
Synchronization Segment
1 Bit Time
1
Page 36
Propagation Segment
1 Bit Time
2
Page 37
Phase Buffer Segment 1
1 Bit Time
3
Page 38
Phase Buffer Segment 2
1 Bit Time
4
Page 39
Bit Lengthening
Needed Sample
tq Point
Phase Phase Next
Sync- Propagation Buffer Buffer Sync-
Segment Time Segment Segment 1 Segment 2 Segment
Transmitter
(slower)
Page 40
Bit Lengthening (cont.)
Needed Sample
tq Point
Phase Phase Next
Sync- Propagation Buffer Buffer Sync-
Transmitter Segment Time Segment Segment 1 Segment 2 Segment
(slower)
in order to adjust the sample point and the end of the bit time.
Page 41
Bit Shortening
Phase Buffer Phase Buffer Sync- Propagation Phase Buffer Phase Buffer Sync-
Segment 1 Segment 2 Segment Time Segment Segment 1 Segment 2 Segment
Transmitter
(faster) next edge for Re-synchronization is 1 TQ too early...
Receiver
Phase Buffer Phase Buffer Sync- Propagation Phase Buffer Phase Buffer Sync-
(slower) Segment 1 Segment 2 Segment Time Segment Segment 1 Segment 2 Segment
If, on the other hand, the transmitter oscillator is faster than the
receiver oscillator, the next falling edge used for resynchronization may
be too early. So Phase Buffer Segment 2 in bit N is shortened...
Page 42
Bit Shortening (cont.)
Transmitter
(faster) Phase Buffer segment 2 in bit n is shortened by 1 TQ
Phase
Receiver Buffer
Phase Buffer Segment Sync- Propagation Phase Buffer Phase Buffer Sync-
(slower) Segment 1 2 Segment Time Segment Segment 1 Segment 2 Segment
in order to adjust the sample point for bit N+1 and the end of the bit
time
Page 43
Synchronization Jump Width
Page 44
Bit Timing
1 Bit Time
Page 45
Why Program the Sample Position ?
1 Bit Time
Maximum
Synchronization
Jump Width (4)
Transmit Early
Point Sample
Point
Page 46
Why Program the Sample Position ? (cont.)
1 Bit Time
Transmit Late
Point Sample
Point
Page 47
Relation between Baud Rate and Bus Length
Page 48
CAN Bus Line Characteristics - Wired-AND
5V
Two logic states: CAN-Bus
1 = recessive (single logical
0 = dominant Bus State: dominant bus line)
A B C BUS
D D D D
D D R D
D R D D R T R T R T
recessive
recessive
dominant
D R R D
R D D D
R D R D
R R D D
R R R R
Node A Node B Node C
CAN is serial bus system with one logical bus line. It has an open,
linear bus structure with equal bus nodes. The number of nodes on the
bus is not restricted by the protocol and may be changed dynamically
without disturbing the communication of other nodes. This allows easy
connection and disconnection of bus nodes, e.g. for addition of system
function, error recovery or bus monitoring.
The CAN bus line has two logic states: a recessive state and a
dominant state. The actual bus state is wire-AND of all node states.
This means, that recessive bits (mostly, but not necessarily equivalent
to the logic level "1") are overwritten by dominant bits (mostly logic level
"0"). As long as no bus node is sending a dominant bit, the bus line is in
the recessive state, but a dominant bit from any bus node generates the
dominant bus state.
Page 49
ISO Physical Layer
CAN_Txd
Physical CAN Bus
CAN_Rxd (Differential, e.g Twisted Pair)
CAN_Txd
Differential
CAN_Rxd Bus Driver
Therefore, for the CAN bus line, a medium must be chosen that is able
to transmit the two possible bit states dominant and recessive. One
of the most common and cheapest ways is to use a twisted wire pair.
The bus lines are then called "CAN_H" and "CAN_L". The two bus lines
CAN_H and CAN_L are driven by the nodes with a differential signal.
The twisted wire pair is terminated by terminating resistors at each end
of the bus line, typically 120 Ohms.
But also an optical medium would be possible for CAN. In this case,
the recessive state would be represented by the signal light off, the
dominant state by the signal light on.
Page 50
CAN and EMI
V
Node A Node B Node C
CAN_H
U diff
CAN_L
t
CAN_H
120 120
Ohm Ohm
CAN_L CAN-Bus
EMI
Page 51
Standardization Issues
CAN
High
Speed
bit rate / kbps CAN
ISO-IS
Low
11898
Speed
ISO-IS
1000
11519-2 Engine
Class C management,
125 Gearbox, ABS
Class B dashboard,
diagnostics
10
Class A body
control
Real-time capability
Page 52
Physical Layer according to ISO-IS 11898
CAN
Node 1 Node 32 High
Speed
ISO-IS
11898
...
Page 53
Bus Levels according to ISO-IS 11898
CAN
High
V Recessive Dominan Recessive Speed
t ISO-IS
5
11898
4 UCAN_H
3.5 V
3 U diff
2.5 V
2
1.5 V
1 UCAN_L
These are the bus levels according to ISO-IS 11898. A recessive bit is
represented by both CAN bus lines driven to a level of about 2.5 V so
that the differential voltage between CAN_H and CAN_L is around 0 V.
A dominant bit is represented by CAN_H going to about 3.5 V and
CAN_L going to about 1.5 V. This results in a differential voltage for a
dominant bit of about 2V.
Page 54
CAN bus connectors according to CiA-DS 102-1
2: CAN_L 3: 0V (ground)
CiA
bus line 4: reserved DS
102-1
1: reserved 1 2 3 4 5 5: reserved
6: 0V
9: V+ (opt.
(ground)
6 7 8 9 power supply)
7: CAN_H 8: reserved
bus line
Page 55
Typical CAN Implementations
Node A Node B
e.g. e.g.
Host-Controller 80C166 C167CR
or C515C
CAN-Transceiver
CAN-Bus
Page 56
Basic CAN controller
Status/Control
Registers
L
low high
Host
CPU
CAN CAN
Bus Interface
Bus Protocol
Host CPU load
Controller Transmit
Inter-
Buffer
face Tx Rx
Acceptance Receive
Filtering Buffer(s)
q Use in CANs with very low baudrates and/or very few messages only
Page 57
Full CAN controller
Status/Control
CAN CAN Registers
Bus
Bus Interface
Protocol
Controller Message
Object 1
Host
Inter- J
face low high
Acceptance Message
Filtering Object 2 CPU load
...
Host CPU
Message
Object n
Receive
Buffer(s)
Page 58
Complete CAN Capability
Products at Each Price-Performance Point
price C167CR
Flash
ROM
C164CI
OTP
ROM
C515C OTP
ROM
C505C
OTP
ROM
81C91
81C90
performance
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 59
User Benefits
1
User Benefits (cont.)
2
Application Examples
CAN in trains
High need of data exchange between the different electronic
subsystem control units (i.e. acceleration, braking, door control,
error messages etc. as well as diagnostics).
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 63
3
Application Examples (cont.)
q Two different CAN modules can be found in the Module Library of Siemens
Microcontrollers:
4
Features of the CAN Module on
C167CR / C164CI / C515C / C505C
q Functionality corresponds to AN 82527
q Complies with CAN spec V2.0B active
(Standard- und Extended-CAN)
q Maximum CAN transfer rate (1 MBit/s)
q Full CAN Device
15 message objects with their own identifier
and their own status - and control bits
Each message object can be defined
as transmit - or receive object
5
Connecting the C167CR to CAN
C167CR
CAN-Bus
Transceiver
CAN_L CAN_H
P4.5
Pa.b CAN_RxD 90 Receive
CAN_H
Connection P4.6
to the 91
CAN_TxD Transmit
Application CAN_L
Pc.d 47 (Standby)
P2.0
R(opt) Vref
n.c.
ROM/
EPRON Instr./Data CPU Data 2 KByte
FLASH 32
16
XTAL
PLL
OSC
PEC
External Instr./Data
P4.5/ CAN RxD
Watchdog
XBUS (16-bit NON MUX Data / Addresses)
MultiFunctional
Sync.
Port 6
ADC (SPI)
Timer 0
PT 2
8 XBUS Control, 16 Channels 32 Channels
5 * CS Logic ASC SSC T3 T5 PT 3
Port 0
Timer 7
PT 4
Timer 8
BRG BRG T4 T6
16
Port 4
16 16 15 16 8 8
Siemens Microelectronics, Inc.
October 98
CANPRES Version 2.0 Slide 70
6
C167CR Full CAN Module - General Registers I
Global
Control/Status bits
EF00H
Control / Status
0xEF00 General Registers Register
0xEF10 Message Object 1
Message Object 2
Interrupt
EF02
H
source
0xEF20 Interrupt
Register
0xEF30 Message Object 3
0xEF40 Message Object 4 Bit Timing EF04H
0xEF50 Message Object 5 Register
7
C167CR - Definition of Bit Characteristics
q Characteristics are defined via Bit Fields in the Bit Timing Register :-
15 0
EF00H
Control / Status
0xEF00 General Registers Register
0xEF10 Message Object 1 Acceptance
EF02H
Filtering
0xEF20 Message Object 2 Interrupt
0xEF30 Message Object 3 Register Mask for Standard
0xEF40 Message Object 4 Bit Timing EF04HFrames
0xEF50 Message Object 5 Acceptance Filtering Register
0xEF60 Message Object 6
0xEF70 Message Object 7
Mask for Extended Global Mask EF06H
Short
0xEF80 Message Object 8 Frames
0xEF90 Message Object 9 Acceptance
EF08H
8
C167CR - Global Mask Registers
10 0
1 0 0 1 0 0 1 0 0 0 0 ( = 0x490)
1 0 0 1 0 0 1 0 0 0 1 ( = 0x491)
IDs received:
1 0 0 1 0 0 1 0
1 0 0 0 ( = 0x498)
1 0 0 1 0 0 1 0
1 0 0 1 ( = 0x499)
9
C167CR Full CAN Module - Registers
10
C167CR - Message Configuration Register
7 0
DLC 0 0
DIR XTD
11
C167CR - Message Arbitration Registers
15 0
12
C167CR - Message Control Register
13
C167CR - Message Data Registers
14