CAN is two formats: Standard format (11-bit Identifier) and Extended format (29-Bit Identifier).
CAN Frame format:
It carries data from transmitter to the receiver.
SOF: Is always dominant (low(0))., because all nodes are synchronized within this segment only. On edge is expected to lie within this segment only. The Hard synchronization is done in the SOF.
Arbitration: the identifier of the message.
What is mean by arbitration?
In CAN if bus is idle any node can transmit data if two or more nodes transmitting the data at the same time the bus conflict will occur according to the arbitration the highest priority message will be transmitted first. Highest priority means the lowest numeric value will be the highest priority i.e., dominant bit.
RTR: (remote transmission request) is zero(dominant) for data frame 1(recessive) for remote frame.
If we transmitting data and remote frame then data frame will be transmitted first because RTR is 0 for data frame which is the highest priority.
IDE: (Identifier Extension Bit) Is 0 (dominant) for standard format and 1(recessive) for extended format.
If we transmitting Standard and extended data frame then standard frame will be transmitted first because IDE is 0 for standard format which is the highest priority.
Dominant is the standard format and recessive is the extended format.
Control field: Total of 6 bits in this 4 bits are used for DLC(Data length code) from 0000 to 1000 according to 8421 code (possible up to 8bytes). Reserved 2 bits are r1 and r0 in standard format r1 is for IDE and r0 is reserved.
Data field: is up to 8 bytes data transmission. From 0 to 64 bits of data transmission.
CRC: (Cyclic redundancy check) is of 16 bits. 15 bit CRC and 1 delimiter. Polynomial is used for CRC checking.
ACK: 2 bits. ACK Slot and ACK delimiter. In ACK field the transmitting node sends two recessive bits if the receiving node successful reception of message it will indicate to the transmitting node by sending dominant bit to the ACK slot i.e., suppression of the recessive bit.
EOF: (End of frame) 7 recessive bits.
IFS: (Inter frame Space) 3 bits long.
These two fields EOF and IFS are to indicate the BUS Idle condition.
Remote frame: RTR is 1(recessive). In this there is no data field.
To request the transmission of the data frame with the same identifier. Most of them recommended that don’t use the remote frame instead of request the data put the response in the bus. If we are putting the data on the bus then any node needs the data then that node can take it easily unnecessary transmission of remote frame.
It is transmitted by any node by detecting the error on the bus.
If error is detected it can put 6 error flags on the bus. Upto 12 error flags is possible. After 6 dominant bits don’t put the error frame if also the error frame is detected wait for the successful transmission of the message.
Error Counters: TEC and REC (transmit error counter and receive error counter) when it is in 96 warning limit and TEC and REC are >127 then it is in error passive state. TEC>256 then it is in bus off state. A node in bus off to come back to error active state wait for the 128 occurrences of 11 consecutive bits.
OR most preferable answer for the interviewer is we can reset by the software i.e., CAN_Reset API in the driver development module.
Types of Errors:
Bit Error: Whenever a node transmitting the data it is also monitors the data until the receiver receives the data. It is expected that the data to be same until the receiver receives. For example if the node is transmitting 0(dominant) to the bus and it is detected 1(recessive) in the bus then it is bit error.
ACK Error: whenever the transmitting node doesn’t monitor the dominant bit in the ACK slot then it is ACK error.
Stuff Error: After 5 consecutive bits the 6th bit will be invert (opposite) of the 5th bit otherwise it will be Stuff Error.
Normally the data frame will be 108 bits for standard format and 108+18 for the extended format but the two standard and extended formats are varied (total bits in both formats) based on number of stuff bits inserted.
The stuff bits inserted because for the error detection. After 5 consecutive bits if we are inserting the 6th bit opposite to the 5th bit on edge is occurred the Resynchronization is possible.
The Resynchronization is for the error detection.
Synchronization: It is the co-ordination of events.
CAN is based on NRZ signaling why because the bit time is constant for the 1 successful bit level.
In RZ signaling synchronization possible is very easy but CAN is chosen only NRZ. Because in CAN bit time calculation the entire bit time is constant for one bit level.
Form Error: In CAN formats the fixed formats bits are CRC Delimiter, ACK Delimiter and EOF these are fixed format fields always recessive for the resynchronization. If any of the bits are dominant then it is form error.
CRC Error: The result of the CRC calculation by transmitting side and receiving side is not same then it is CRC error.
It is like IFS (inter frame space) to provide the delay between the 2 data frames.
Bit timing Calculation in CAN:
In bit timing calculation the CAN bit timing is Comprised into four segments.
Synchronization segment: this is 1 TQ long. An edge is lie within this segment only. The Hard synchronization is done within this segment only.
TQ: (Time quanta) It is a fixed unit of time derived from the master clock.
1 Time quanta is equal to 1 clock period. It is 1 for the synchronization segment and 1TQ to 8 TQ for Propagation segment and Phase buffer segments.
If the CAN bit rate is 1Mbps then TQ is 12 other than all bit rates (500kbps to 10kbps) the time quanta is 12 and it is fixed.
Propagation Segment: The physical delay adjustments.
Phase Buffer Segment-1 and Phase Buffer Segment-2: The phase error adjustments lengthened or shorthand based on the SJW (synchronization jump width).
Sample Point: It is to indicate where the bus level is read. It is after the phase buffer segment-1 and before the phase buffer segment-2. It is to be adjusted based on the phase buffer segment-1 and phase buffer segment-2.