No Slide Title
Download
Report
Transcript No Slide Title
An Introduction to CAN
CAN Basics 2
Renesas Interactive
Renesas Technology America Inc.
1
Key reasons to use CAN
•
Scalability
•
•
•
•
•
•
Low wiring cost
Low node connection costs
More and more chips
More off the shelf tools
Knowledge base growing
Reliability (error free)
2
CAN Message Frames
• Data Frame - Carries the actual data
• Error Frame - When error is detected by any node’s
hardware
• Overload Frame - Request a delay on the bus
• Interframe Space - Provides minimum spacing between data and remote
frames
Allows error frames priority
• Remote Frame - Request transmission of Data Frame.
3
Data Flow
Transmitting Node
Node configured to
receive identifier
Node not configured to
receive identifier
MCU Firmware
MCU Firmware
MCU Firmware
identifier [id_n]
Data [values_x]
Data [values_x]
Tx Mail Box [id_n]
Tx Mail Box [id_c]
Tx Mail Box [id_b]
Data [values_x]
Rx Mail Box [id_b]
Rx Mail Box [id_d]
Rx Mail Box [id_n]
Rx Mail Box [id_c]
Rx Mail Box [id_b]
Data [values_x]
Rx Mail Box [id_a]
CAN Peripheral
CAN Peripheral
CAN Peripheral
CAN Transceiver
CAN Transceiver
CAN Transceiver
Rx Mail Box [id_c]
Data Frame is broadcast to the bus [id_n][value_x]
4
Data Frame
Data Field
0 to 8 bytes
CRC
CRC Delimiter
ACK slot
ACK Delimiter
Data Length
Code (4 bits)
Identifier
Remote Request
ID Extend
reserved 0
Start of Frame
Standard ID
End of
Frame
•
•
•
•
•
•
•
Data Field
0 to 8 bytes
Start of Frame
Arbitration Field
Control Field
Data Field
CRC
ACK Field
End of Frame
5
CRC
CRC Delimiter
ACK slot
ACK Delimiter
Identifier
(second part)
Data Length
Code (4 bits)
Remote Request
reserved 1
reserved 0
Identifier
(first part)
Substitute RR
ID Extend
Start of Frame
Extended ID
End of
Frame
Start of Frame
• A single dominant bit while the bus is idle
• All nodes synchronize timing to leading edge
Start of Frame
All nodes
synchronize to
edge
6
Identifier
7
Identifier
(second part)
Remote Request
reserved 1
Identifier
(first part)
Remote Request
ID Extend
Identifier
Substitute RR
ID Extend
Extended; 29-bits
Start of Frame
Standard; 11-bit identifier
Start of Frame
Arbitration Field
Arbitration
Handling collisions
Carrier Sense Multiple Access/Collision Resolution
= CSMA/CR
By using Dominant and Recessive Bits
8
Control Field
Control Field contains the DLC
Data Length
Code (4 bits)
Remote Request
reserved 1
reserved 0
• 2 bits reserved
• 4 bits Data Length Code; number of Data Field bytes
Data Length Code
Number of
Data Bytes
DLC3
DLC2
DLC1
DLC0
0
0
0
0
0
1
0
0
0
1
2
0
0
1
0
3
0
0
1
1
4
0
1
0
0
5
0
1
0
1
6
0
1
1
0
7
0
1
1
1
8
1
0
0
0
9
Data Field
Data Length
Code (4 bits)
• Data content = payload
of the frame
• 0-8 bytes
• MSB transmitted first
Data Field
0 to 8 bytes
10
CRC
CRC Field
CRC
11
CRC Delimiter
ACK slot
• 15 bit CRC value followed by a recessive delimiter
• Generated by transmitter node’s HW and verified in
receiver’s HW
• CRC polynomial: x15+x14+x10+x8+x7+x4+x3+1
CRC Delimiter
ACK slot
ACK Delimiter
ACK Field
ACK FIELD = ACK SLOT + ACK
DELIMITER
All receivers that received valid
message reports with a ’dominant’
End of
bit during the ACK slot
Frame
Any receiver that disagrees votes no
after the delimiter with an error
flag
12
DATA FRAME and REMOTE FRAME
delimited by ‘End of Frame’
consisting of seven recessive’ bits.
Gives a break before the next frame..
13
ACK Delimiter
End of Frame
End of
Frame
Error detection
Locally detected errors
When is an error frame sent?
•
•
•
•
•
Bit error -receive bit at sender not equal to transmit bit.
Bit stuffing violation -max 5 bits with same polarity
CRC error -checksum violation
Form error -bit pulse malshaped
Ack error -no dominant level in ACK slot so sender must retransmit
14
What is needed?
•
•
•
•
Firmware
CAN controller
CAN transceivers
A physical media
15
Example of Renesas CAN MCUs
•
SH705x series
• Automotive Powertrain
•
SH7047 series
• General purpose SH2…soon updated derivative available.
•
M32R/ECU series
• Automotive Powertrain
•
M32C series
• General purpose (1-3 channels of CAN)
•
M16C/6N series
• M16C/62 family with CAN. General purpose.
•
M16C/29 series
• General Purpose M16C/Tiny with CAN.
•
M16C/10 series
• Better off with M16C/Tiny or R8C/Tiny
•
R8C/Tiny series
• General Purpose
16
Question 1
Which is normally by far the most common frame type?
1.
2.
3.
4.
Data Frame
Error Frame
Overload Frame
Remote Frame
A: 1
B: 2
C: 3
D: 4
17
Question 2
Which of these statements is false?
1.
2.
3.
4.
The data field in a data frame can consist of max 255 bytes
The data field has only 8 bytes
You must specify for each data frame how many data bytes follow
Remote frames are not necessary to use CAN
A: 1
B: 2
C: 3
D: 4
18
Question 3
Which of these is false?
1.
2.
3.
The CRC field is sent by all receivers and verified by the transmitter.
Each receiver generates a CRC on the observed data frame and
compares it with the transmitted CRC check value.
Every receiver which has received a valid message correctly, reports
this to the transmitting node with a ’dominant’ bit during the ACK slot.
Any node that disagrees, votes no after the delimiter by sending an
error flag.
A: 1
B: 2
C: 3
19
Question 4
When is an error frame sent?
1.
2.
3.
4.
Bit stuffing violation; > 5 bits with same polarity
CRC error; checksum violation
Form error; bit pulse malshaped
Ack error; no dominant level in ACK slot so sender must
retransmit
A: 1-3
B: 2-4
C: 2 and 4
D: All above
20
Glossary
•
•
•
•
•
•
•
•
•
•
•
•
•
Advanced CAN: CAN peripheral with varying numbers of buffers configurable for transmit/receive. Receive buffers have
hardware filtering on at least mask/match identifier content.
Basic CAN: CAN peripheral with no hardware filtering. Typically two receive buffers act as FIFO accepting all bus traffic. Usually
one transmit buffer.
Bit Time: Nominal time of one bit on the CAN bus. Made up of multiple segments that allows each node to synchronize to the
received bus traffic. All nodes on a bus must be configured to the same (nominal) bit time.
CAN: Controller Area Network
CAN 2.0B: Version 2.0 was the last version of CAN defined by Bosch. Part B added extended identifiers and the idea of hardware
filtering.
CIA: CAN in Automation. Group controlling the CANOpen protocol.
CANOpen: Multi-area communication protocol using CAN.
CRC: Cyclic Redundancy Check
DeviceNet: Industrial communication protocol using CAN.
Dominant/Recessive: Dominant bits on physical layer can override recessive bits.
Filters: Hardware in the CAN peripheral that can mask/match bits within the identifier field used to determine whether or not route
bus data to a mailbox.
GM LAN 3.0: GM protocol, encompasses all GM serial protocols.
Identifier: Frame field that indicates the message content. This field also is used to arbitrate the message priority on the bus;
lower identifier is higher priority.
•
•
•
•
•
•
•
•
•
Standard Format; frames use 11 bit identifier.
Extended Format “29 bits
ISO 11898: ISO standardized version of CAN.
Mailbox: CAN hardware buffer that can be used to transmit or receive data. Most full CAN implementations have at least 16
mailboxes.
ODVA: Open DeviceNet Vendor Association. Group controlling DeviceNet protocol.
Time Quanta: Smallest time unit used by CAN. Multiple time quanta make up the segments of a bit time.
TT CAN: Time Triggered CAN. More deterministic CAN by assigning time slots when nodes may transmit.
FlexRay: Next generation automotive network. Time slots on the bus provide more deterministic behavior.
Vector-CanTech: Supplier of the majority of CAN software drivers and tools to North American and European automobile ECUs.
21
Come back for more!
End CAN Basics 2
22