1 Can Protocol and Terminology
Controller Area Network (CAN) is a multi-master serial data bus which uses Carrier Sense Multiple Access/Collision Resolution (CSMA/CR) to determine access. Message transfer over CAN is controlled by 4 different types of frame: Data frames, Remote Transmit Request (RTR) frames, Overload frames and Error frames. Each CAN data frame is required to have a unique identifier. Identifiers may be 11-bit (standard format) or 29-bit (extended format).
The identifier serves two purposes beyond simply identifying the message. First, the identifier is used as a priority to determine which message among those contending for the bus will be transmitted next. Second, the identifier may be used by receivers to filter out messages that they are not interested in, and so reduce the load on the receiver's host controller.
1.1 Priority Based Arbitration
Priority of an Identifier defines a static message during bus access while Arbitration in CAN protocol tells us that, when the bus is free any node may start to transmit a message, if multiple nodes start transmitting at the same time the bus access conflict is resolved by bit-wise arbitration using identifier. If Data Frame and Remote Frame with the same identifier are initiated at the same time, the data Frame prevails over the Remote Frame. The CAN physical layer supports two states termed dominant (‘0’) and recessive (‘1’). If two or more CAN controllers are transmitting at the same time and at least one of them transmits a ‘0’ then the value on the bus will be a ‘0’. This mechanism is used to control access to the bus and also to signal errors. The CAN protocol calls for nodes to wait until a bus idle period is detected before attempting to transmit. If two or more nodes start to transmit at the same time, then by monitoring each bit on the bus, each node can determine if it is transmitting the highest priority message (with a numerically lower identifier) and should continue or if it should stop transmitting and wait for the next bus idle period before trying again. As the message identifiers are unique, a node transmitting the last bit of the identifier field, without detecting a ‘0’ bit that it did not transmit must be transmitting the message with the lowest numerical value and hence the highest priority that was ready at the start of arbitration. This node then continues to transmit the remainder of its message, all other nodes having backed off. The requirement for a node to be able to overwrite a recessive bit, and the transmitting node detect this change, limits the combination of physical length and speed of CAN bus. The duration of each bit must be sufficient for the signal to propagate the length of the network. This limits the maximum data rate to 1Mbit/s for a network up to 40m in length or to 125Kbit/s for a 500m long network. The arbitration mechanism employed by CAN means that messages are sent as if all the nodes on the network shared a single global priority based queue. The above high level description is a somewhat Simplified view of the timing behavior of CAN. CAN does not have a global concept of time, rather each CAN controller typically has its own clock which, within a tolerance specified by the protocol, may drift with respect to the clocks of other nodes.
The CAN protocol therefore requires that nodes re-synchronize on each message transmission. Specifically, every node must synchronize to the leading edge of the start of frame bit caused by whichever node starts to transmit first Normally, CAN nodes are only allowed to start transmitting when the bus is idle. Thus, when the bus is idle beyond the 3-bit inter-frame space and a node n starts to transmit a message beginning with the dominant start of frame bit (“0”), then all the other nodes synchronies on the leading edge of this bit and become receivers – i.e. they are not permitted to transmit until the bus next becomes idle. In this case any message that becomes ready...Read more »