Datasheet
Copyright © 2013 ARM Ltd. All rights reserved
CAN: Controller Area Network Lab using ST STM32 Cortex-M processors. www.keil.com
10
Sequence of Transmitting Data on the CAN Bus:
1. You give the transmitter the ID, the size of the ID (IDE), the number of data bytes (DLC) and the data if any.
2. You then set a bit to tell the transmitter in the CAN controller to send this frame.
3. Any node(s), seeing the bus idle for the required minimum time, can start sending a CAN frame.
4. All other nodes start receiving it except those also starting to transmit a message at the same time.
5. If any other node starts transmitting: the arbitration process starts – the node with the highest priority (lower ID value)
continues and lesser priority nodes stop sending and immediately turn into receivers and receive the priority message.
Note: The losing node “knows” the beginning ID of the other message. CAN arbitration is non-destructive.
6. At this point, only one node is transmitting a message and no other will start during this time else a bus error happens.
7. When the transmitting node has completed sending its message, it waits one bit time for the 1 bit ACK field to be
pulled to a logic 0 by any other node (normally all of them) to signify the frame was received without errors.
8. If this happens, the transmitting node assumes the message reached its recipient, sends the end-of-frame bits and goes
into receive mode or starts to send its next message if it has one. The receiving nodes pass the received message to
their host processors for processing unless the acceptance filtering prevents this action.
9. At this time, any node can start sending any message or the bus goes into the idle state if none do. Go to 1.
10. If # 7 does not happen (ACK bit not set) then the transmitting retransmits the message at the earliest time allowed. If
the ACK bit is never set, the transmitting node will send its initial message forever.
Transmitting Notes:
How do I transmit my message ? Easy – you create the CAN frame you want to send by loading up the IDE, ID,
DLC and any data byte registers in the CAN controller and then, in most controllers, you set a bit that triggers
sending the frame as soon as legally possible. After this, the controller takes care of sending all frame bits. Unless
the controller signals otherwise to the processor, you can assume the message was sent.
How does a node know when it should transmit a message ? The CAN controller continuously monitors the bus.
When it sees > = required number of idle bits (11 after ACK bit), it starts transmitting. It is quite possible for other
node(s) to start transmitting at the same time. Arbitration decides which message is actually transmitted.
What if there is an error ? All nodes, including the transmitting node, monitor the bus for any errors. If an error
condition is detected – a node or nodes signal to the other nodes there is an error by holding the bus at logical 0 for
at least 6 bus cycles. At this point, all nodes note this error event and take appropriate action. The message being
sent (and now aborted) will be resent but only for a certain number of times. See Bus Errors on page 8.
What if no node wants or uses the message ? Nothing. The ACK bit only says that the CAN frame was
transmitted without errors and at least one node saw this frame error free. Remember the transmitting frame can’t
ACK itself. CAN does not provide any acknowledgment mechanism that a frame was used or not by its intended
recipient. If needed, you will have to provide this in your software as many systems do.
TIP: In a periodic system, if a node misses a message, it doesn’t matter much as a copy frame will be along shortly.
How do I add a node ? Just attach CAN-Hi and CAN-Lo signals to the existing network. If your CAN controller
is not initialized, nothing will happen. If it is initialized to the correct frequency, it will start listening to the bus and
set the ACK bit if appropriate. Until your software reads messages out of the buffer, messages will be lost.
What happens if I “hot plug” a node on the bus ? Usually any disturbances will be taken care of by the CAN
error detection schemes. A message that is sufficiently corrupted will result in a bus error and subsequent
retransmission. If the TEC register is high or the disturbances are of a long duration, a bus-off might result.
Arbitration Notes:
1. Arbitration is performed bit-wise. That is, bit by bit on the ID (11 or 29 bit) and the IDE bit. No other bits are used.
2. The node that wins arbitration is not slowed or delayed by this process. CAN arbitration is non-destructive.
3. The losing nodes, if there are any, will attempt to retransmit at the next idle bus time.
4. CAN is not deterministic. This means you are usually never sure when a CAN message will appear on the bus.
5. If you need determinism, try Time Triggered CAN. TTCAN is described in ISO 11898-4. It is a software layer that
sits on top of regular CAN. It places frames into specified time slots.