CAN Protocol
CAN Protocol
Frame Format
Defines both a standard and an extended frame format They differ in the size of the identifier field and for some other bits in the arbitration field Standard frame format also know as CAN 2.0A format defines an 11 bit identifier field, means upto 2048 different identifiers are available to applications running in the same network Extended frame format CAN 2.0B assigns 29 bits to the identifier- upto half a billion different objects could exist in the same network
Data Frame
Data frames are used to send information over the network Each data frame begins with an SOF bit at the dominant level- its role is to mark the beginning of the frame. SOF bit is also used to synchronize the receiving nodes After SOF bit the arbitration field follows, includes identifier field and remote transmission request (RTR) bit Identifier field identifies the content of the frame, also used by the MAC layer to detect and manage the priority of the frame, used when collision occurs The RTR bit used to discriminate between data and remote frames RTR bit = 0 data frame , =1 remote frame A data frame has a higher priority than a remote frame having the same identifier
Next to the arbitration field comes the control field In the case of the base frames, control field includes IDE bit, reserved bit r0 In extended frame- IDE bit belong to the arbitration field as well as substitute remote request (SRR) bit a placeholder that is sent at recessive value to preserve the structure of the frames In this case IDE bit is followed by the identifier extension and then by control field Control field starts with r0 and r1-reserved bits, followed by data length code (DLC)- it specifies the length of the data field
Size of the data field is 8bytes Fro the DLC field values ranging from 0 to 8 are allowed Higher values (9 to 15) can be used for application specific purpose The CRC and the acknowledgement fields are placed after the data field The frame is closed by the end of the frame (EOF) field, made up of 7 recessive bits Different frames are interleaved by the intermission (IMS) gap, which consists of 3 recessive bits and effectively separates consecutive frames exchanged on the bus
Remote Frames
They are very similar to data frames The only difference is that they carry no data They are used to request that a given message be sent on the network by a remote node Requesting node does not know who is the sender, it is upto the receiver to discover the one that has to reply The DLC field in the remote frame is not used by the CAN protocol Error and Overload frames They are used to notify nodes in the network that an error has occurred They consists of 2 fields error flag and error delimiter Two kinds of error flags:
Active error flags 6 dominant bits Passive error flags 6 recessive bits
An active error flag violates the bit stuffing rules hence it enforces an error condition, starts transmitting an error flag on its own In this way there can be from 6 to 12 dominant bits on the bus as a consequence of the transmission of an error flag Error delimiter is made up of 8 recessive bits
Bus arbitration The most distinctive feature of the medium access technique of CAN is the ability to resolve any collision that may occur on the bus in a deterministic way This is made possible by the arbitration mechanism, which effectively finds out the most urgent frame each time there is a contention for the bus The CAN arbitration scheme collision is resolved by stopping transmission of frames involved except the one which is assigned the highest priority The arbitration technique exploits the peculiarity of the physical layer of CAN, which conceptually provides a wired and connection scheme among all nodes When transmitting, each node compares the level sensed on the bus to the value of the bit which is being written out. If the node is transmitting a 1 and the level on the bus is 0, the node understands that it has lost the contention and withdraws immediately and sets its output port to 1, to read the incoming frames
The binary count down technique ensures that, in the case of a collision, all nodes that are sending lower priority frames will abort their transmission, except for the one which is sending the frame with the highest priority This implies that no two nodes in a CAN network can transmit message at the same time characterized by the same identifier If this is not the case, unmanageable collisions could take place which causes transmission errors Because of the automatic retransmission feature of CAN controllers, this would lead to almost certainly to a burst of errors on the bus, which in turn causes the nodes involved to be disconnected by the fault confinement mechanism. This implies that in general only one node can be the producer of each object