5. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
CAN Overview
Standard CAN
Multi-master protocol
Broadcasting
Event-Driven
Asynchronous communication (Event Triggered)
Serial communication technology
Priority-based bit-wise arbitration
Variable message priority based on 11-bit
(or extended 29 bit) packet identifier
Originally developed by Robert Bosch for
automobile in-vehicle network in the 1980s
Differential, two wire with speed 1 Mbps
CSMA-CA= CSMA with Collision Avoidance
5
CANController Area Network
Overview
General
Characteristics
Types of
CAN Messages
CAN bus
CAN
transceiver
9. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Arbitration type
ND + CSMA/CA + AMP
If two messages are simultaneously
sent over the CAN bus, the bus
takes the “logical AND” of the
signal
Hence, the messages identifiers
with the lowest binary number
gets the highest priority
Every device listens on the channel
and backs off as and when it
notices a mismatch between the
bus’s bit and its identifier’s bit
9Non-Destructive + Carrier Sense Multiple Access /
Collision Avoidance + Arbitration on Message Priority
11. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
CAN (link layer and Physical layer)
1. Physical Layer
2. Data Link Layer
3. Network Layer
4. Transport Layer
5. Session Layer
6. Presentation Layer
7. Application Layer
Standard CAN
implementation
Partially
implemented by
higher-level CAN
protocols
(CANOpen)
ISA/OSI Reference Model
Managed in
Hardware.
Dramatic Real-time
advantage to
System Design
11
The standard CAN
implementation bypasses the
connection between the Data
Link layer and the
Application layer. The layers
above the Data Link Layer are
implemented in software
which as per definition are
called the Higher Layer
Protocol
13. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Message Filtering
A node uses filter (s) to decide
whether to work on a specific
message.
Message filtering is applied to the
whole identifier.
A node can optionally implement
mask registers that specify which
bits in the identifier are examined
with the filter.
If mask registers are
implemented, every bit of the
mask registers must be
programmable.
13
Transmitting Node
MCU Firmware
Identifier [id_n]
Data [values_x]
CAN Peripheral
Tx Mail Box [id_n]
Data [values_x]
Rx Mail Box [id_c]
Rx Mail Box [id_b]
CAN Transceiver
Node Configured to
receive identifier
MCU Firmware
Identifier [id_n]
Data [values_x]
CAN Peripheral
Data [values_x]
CAN Transceiver
Rx Mail Box [id_c]
Rx Mail Box [id_b]
Rx Mail Box [id_n]
Node not Configured to
receive identifier
MCU Firmware
CAN Peripheral
CAN Transceiver
Rx Mail Box [id_d]
Rx Mail Box [id_b]
Rx Mail Box [id_c]
Rx Mail Box [id_a]
Data Frame is broadcast to the bus ][value ]id n_[ x_
14. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Data Flow in CAN
Transmitting Node
MCU Firmware
Identifier [id_n]
Data [values_x]
CAN Peripheral
Tx Mail Box [id_n]
Data [values_x]
Rx Mail Box [id_c]
Rx Mail Box [id_b]
CAN Transceiver
Node Configured to
receive identifier
MCU Firmware
Identifier [id_n]
Data [values_x]
CAN Peripheral
Data [values_x]
CAN Transceiver
Rx Mail Box [id_c]
Rx Mail Box [id_b]
Rx Mail Box [id_n]
Node not Configured to
receive identifier
MCU Firmware
CAN Peripheral
CAN Transceiver
Rx Mail Box [id_d]
Rx Mail Box [id_b]
Rx Mail Box [id_c]
Rx Mail Box [id_a]
Data Frame is broadcast to the bus ][value ]id n_[ x_
14
17. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Data Frame
17
A data frame consists of seven fields: start-of-frame, arbitration,
control, data, CRC, ACK, and end-of-frame.
• A single dominant bit to mark the beginning of a data frame.
• All nodes have to synchronize to the leading edge caused by
this field.
Start of Frame
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
R
T
R
DLC
4
I
D
E
r
0
ID
11
C
R
C
Delm.
1
A
C
K
Delm.
1
18. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Data Frame
18
There are two formats for this field: standard format and extended format.
Arbitration Field
The RTR bit is the remote transmission request and must be 0 in a data frame.
The SRR bit is the substitute remote request and is recessive.
The IDE field indicates whether the identifier is extended and should be recessive in
the extended format.
The extended format also contains the 18-bit extended identifier.
standard format
extended format
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
S
R
R
DLC
4
r
0
r
1
ID
11
I
D
E
ID
18
R
T
R
C
R
C
Delm.
1
A
C
K
Delm.
1
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
R
T
R
DLC
4
I
D
E
r
0
ID
11
extended format
C
R
C
Delm.
1
A
C
K
Delm.
1
19. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Data Frame
19
Control Field
Contents are shown in figure 13.4.
The first bit is IDE bit for the standard format but is used as reserved bit r1 in extended format.
r0 is reserved bit.
DLC3…DLC0 stands for data length and can be from 0000 (0) to 1000 (8).
standard format
extended format
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
S
R
R
DLC
4
r
0
r
1
ID
11
I
D
E
ID
18
R
T
R
C
R
C
Delm.
1
A
C
K
Delm.
1
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
R
T
R
DLC
4
I
D
E
r
0
ID
11
extended format
C
R
C
Delm.
1
A
C
K
Delm.
1
20. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Data Frame
20
CRC Field
It contains the 16-bit CRC sequence and a CRC delimiter.
The CRC delimiter is a single recessive bit.
standard format
extended format
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
S
R
R
DLC
4
r
0
r
1
ID
11
I
D
E
ID
18
R
T
R
C
R
C
Delm.
1
A
C
K
Delm.
1
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
R
T
R
DLC
4
I
D
E
r
0
ID
11
extended format
C
R
C
Delm.
1
A
C
K
Delm.
1
21. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Data Frame
21
ACK Field
Consists of two bits
The first bit is the acknowledgement bit.
This bit is set to recessive by the transmitter, but will be reset to dominant if a receiver acknowledges the
data frame.
The second bit is the ACK delimiter and is recessive.
standard format
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
S
R
R
DLC
4
r
0
r
1
ID
11
I
D
E
ID
18
R
T
R
C
R
C
Delm.
1
A
C
K
Delm.
1
S
O
F
1
Arbitration
E
O
F
7+
Data
(Bytes)
0-8 bytes
C
R
C
15
A
C
K
1
Control
R
T
R
DLC
4
I
D
E
r
0
ID
11
extended format
C
R
C
Delm.
1
A
C
K
Delm.
1
23. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Error Frame
This frame consists of two fields.
The first field is given by the superposition of error flags contributed
from different nodes.
The second field is the error delimiter.
Error flag can be either active-error flag or passive-error flag.
Active error flag consists of six consecutive dominant bits.
Passive error flag consists of six consecutive recessive bits.
The error delimiter consists of eight recessive bits.
23
26. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
CAN Physical BUS
The CAN physical layer has two wires--
CANH and CANL.
The difference in the voltage between
CANH and CANL is called VD.
A logic 1 is represented by the
recessive state, and is defined as
VD less than or equal to 0.5 volts.
A logic 0 is defined by the
dominant state when VD is greater
than or equal to 0.9 volts.
CAN is designed to be used with twisted
pair cabling with 120 ohm characteristic
impedance.
26
31. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_systemThe CAN Tranceivers
CAN_Txd
CAN_Rxd
CAN
Controller
Differential
Transceiver
CAN_Txd
CAN_Rxd
Physical CAN Bus
(Differential, e.g Twisted Pair)
Physical CAN Bus
(Differential, e.g Twisted Pair)
31
• The role of the transceiver is
simply to drive and detect data
to and from the bus.
• It converts the single-ended logic
used by the controller to the
differential signal transmitted over
the bus. It
also determines the bus logic state
from the differential voltage, rejects
the common-mode
noise, and outputs a single-ended
logic signal to the controller
33. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR COM Stack
Communication (COM)
The COM module provides a signal interface to
the RTE based on the I-PDUs.
It is responsible for providing Signal level
access to the application layer and PDU level
access to the lower layers independent of the
protocol.
PDU Router (PDUR)
The PDU Router module provides services for
routing of I-PDUs (Interaction Layer Protocol
Data Units) using communication interface
modules (e.g. Com, CanIf, and CanNm) and
transport Protocol modules (e.g. CanTp).
responsible for routing the PDU to the respective
Bus Specific Interface modules
33
35. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
AUTOSAR COM Stack
Can Interface (CanIf)
The CAN Interface module is located between the low
level CAN device drivers (CAN Driver and Transceiver
Driver) and the upper communication service layers (i.e.
CAN State Manager, CAN Network Management, CAN
Transport Protocol, PDU Router). The CAN Interface
module provides a unique interface to manage different
CAN hardware device types like CAN controllers and
CAN transceivers used by the defined ECU hardware
layout. Thus multiple underlying internal and external
CAN controllers/CAN transceivers can be controlled
by the CAN State Manager module based on a physical
CAN channel related view.
CAN Driver (CAN)
The CAN Driver is part of the lowest layer, performs
the hardware access and offers a hardware
independent API to the upper layer.
35
44. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
TTCAN operating principle
The transmission sequence is set up as a schedule matrix
The matrix is divided into basic cycles.
Each basic cycle starts with a reference message that sets the global time in the
system.
Each basic cycle consists of a number of transmission columns.
The columns can be of three types
1 - Reserved for one particular message
2 - Free for arbitration, all nodes can compete for transmission
3 - Free window, not used but reserved for further expansion
Since the messages have to keep their time slots there is no retransmission of messages.
The slots will have to wait until the next assigned time slot or an arbitration time slot
44
46. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Timing
There are two levels of timing
Level 1
Each node has a 16 bit clock that is retriggered each basic cycle by the
reference message
This is called the local time
Level 2
Each node has a 19 bit clock
The reference message contains information on the time of the global
clock held by the master.
The nodes can correct their clock in a more detailed way by using the
extra bits of their clocks
46
47. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Backup masters
Since the timing of the system is essential it must not fail
To reasure this all nodes on the bus are potential masters To reasure
this all nodes on the bus are potential masters
The nodes have different priority given by the last three bits of the
reference message
If the current master node fails to release a reference message the
other nodes will try to send a reference message after a short time-
out period.
The node with the highest priority will win the arbitration and send its
reference message.
47
53. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Frame structure
synch break
13 bit
synch field identifier
message header
Synchronization
Frame
Synchronization
Field
Identifier Byte
53
Header consists in break,
sync segment and
identifier
Each byte is transmitted
with LSB first
Break field is used to
signal the beginning of
the frame, it is at least
13 nominal bit times
(dominant)
Break field is ended by a
break delimiter which is
at least 1 nominal bit time
The sync field encodes the
value 0x55h
75. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
The Communication Cycle
Static Segment
Reserved slots for deterministic data that arrives at a fixed
period.
Dynamic Segment
The dynamic segment behaves in a fashion similar to CAN and is
used for a wider variety of event-based data that does not
require determinism.
Symbol Window
Typically used for network maintenance and signaling for
starting the network.
Network Idle Time
A known "quiet" time used to maintain synchronization between
node clocks.
75
76. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Clock synchronization and cold
starting
FlexRay has the unique ability to sync up nodes on a network without an external synchronization clock
signal. To do so, it uses 2 special types of frames: Startup Frames and Sync Frames. To start a FlexRay
cluster, at least 2 different nodes are required to send startup frames. The action of starting up the
FlexRay bus is known as a cold-start and the nodes sending the startup frames are usually known as cold-
start nodes.
Once the network is started, all nodes must synchronize their internal oscillators to the network's
macrotick. This can be done using two more synchronization nodes.
Once the network is synchronized and on-line, the network idle time (white space in the diagram) is
measured and used to adjust the clocks from cycle-to-cycle to maintain tight synchronization.
76
84. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
https://www.autosar.org
Embedded Microcomputer Systems Real Time Interfacing Third
Edition Jonathan W. Valvano University of Texas at Austin.
MicroC/OS-II the real-time kernel second edition jean j.labrosse.
RTOS Concepts http://www.embeddedcraft.org.
OSEK/VDX Operating System Specification 2.2.3
AUTOSAR Layered Software Architecture
The Trampoline Handbook release 2.0
Trampoline (OSEK/VDX OS) Test Implementation -Version 1.0,
Florent PAVIN ; Jean-Luc BECHENNEC
84
86. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
Real Time Systems (RETSY)
Jean-Luc Béchennec - Jean-Luc.Bechennec@irccyn.ec-nantes.fr
Sébastien Faucou - Sebastien.Faucou@univ-nantes.fr
jeudi 12 novembre 15
AUTOSAR Specification of Operating System V5.0.0 R4.0 Rev 3
OSEK - Basics http://taisnotes.blogspot.com.eg/2016/07/osek-basic-
task-vs-extended-task.html
OSEK OS Session Speaker Deepak V.
M.S Ramaiah School of Advanced Studies - Bangalore 1
Introducción a OSEK-OS - El Sistema Operativo del CIAA-Firmware
Programación de Sistemas Embebidos
MSc. Ing. Mariano Cerdeiro
86
89. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
AUTOSAR – An open standardized software architecture for the
automotive industry Simon Fürst, BMW 1st AUTOSAR Open
Conference & 8th AUTOSAR Premium Member Conference October
23rd, 2008, Cobo Center, Detroit, MI, USA
http://st.inf.tu-
dresden.de/files/teaching/ws08/ase/03_AUTOSAR_Tutorial.pdf
Institutionen för systemteknik Department of Electrical Engineering
Examensarbete Implementation of CAN Communication Stack in
AUTOSAR Examensarbete utfört i Datorteknik
vid Tekniska högskolan vid Linköpings universitet Av Johan Alexandersson
och Olle Nordin
http://liu.diva-portal.org/smash/get/diva2:822343/FULLTEXT01.pdf
89
90. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
Applying AUTOSAR in Practice Available Development Tools and
Migration Paths Master Thesis, Computer Science Authors: Jesper
Melin
http://www.idt.mdh.se/utbildning/exjobb/files/TR1171.pdf
Freescale AUTOSAR Software Overview.pdf
Introduction to the Controller Area Network (CAN)
CAN Learning From Vector
https://elearning.vector.com/index.php?&wbt_ls_seite_id=490352&root=3
78422&seite=vl_can_introduction_en
90
91. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
AUTOSAR Method, Vector Webinar 2013-04-17
https://vector.com/portal/medien/cmc/events/Webinars/2013/Vector_Web
inar_AUTOSAR_Method_20130417.pdf
AUTOSAR Configuration Process - How to handle 1000s of parameters
Vector Webinar 2013-04-19
https://vector.com/portal/medien/cmc/events/Webinars/2013/Vector_Web
inar_AUTOSAR_Configuration_Process_20130419_EN.pdf
AUTOSAR Runtime Environment and Virtual Function Bus, Nico Naumann
https://hpi.de/fileadmin/user_upload/fachgebiete/giese/Ausarbeitungen_A
UTOSAR0809/NicoNaumann_RTE_VFB.pdf
91
92. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
References
The AUTOSAR Adaptive Platform for Connected and Autonomous
Vehicles, Simon Fürst, AUTOSAR Steering Committee 8th Vector
Congress 29-Nov-2016, Alte Stuttgarter Reithalle, Stuttgart,
Germany
https://vector.com/congress/files/presentations/VeCo16_06_29Nov_Re
ithalle_Fuerst_BMW.pdf
A Review of Embedded Automotive Protocols, Nicolas Navet1,
Françoise Simonot-Lion2 April 14, 2008
https://www.realtimeatwork.com/wp-
content/uploads/chapter4_CRC_2008.pdf
92