If you are looking for “can protocol interview questions” or “can protocol basics, then you are at right place. Previously I have created a list of “embedded c interview questions” that is liked by many people. I have got the response to create a list of interview questions on “CAN Protocol”. So here I have tried to create some collection of “can protocol interview questions” that might ask by your interviewer. I hope these can interview questions will be helpful.
Q1: What is CAN?
A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other in applications without a host computer. It is a message-based protocol, designed originally for multiplex electrical wiring within automobiles to save on copper, but can also be used in many other contexts.
Q2: What is the Standard CAN Frame Formats?
The data frame is the only frame for actual data transmission. There are two message formats:
- Base frame format: with 11 identifier bits
- Extended frame format: with 29 identifier bits
Can Base frame format with explanation:
The frame format is as follows: The bit values are described for CAN-LO signal.
Field name | Length (bits) | Purpose |
---|---|---|
Start-of-frame | 1 | Denotes the start of frame transmission |
Identifier (green) | 11 | A (unique) identifier which also represents the message priority |
Remote transmission request (RTR) (blue) | 1 | Must be dominant (0) for data frames and recessive (1) for remote request frames. |
Identifier extension bit (IDE) | 1 | Must be dominant (0) for base frame format with 11-bit identifiers |
Reserved bit (r0) | 1 | Reserved bit. Must be dominant (0), but accepted as either dominant or recessive. |
Data length code (DLC) (yellow) | 4 | Number of bytes of data (0–8 bytes) |
Data field (red) | 0–64 (0-8 bytes) | Data to be transmitted (length in bytes dictated by DLC field) |
CRC | 15 | Cyclic redundancy check |
CRC delimiter | 1 | Must be recessive (1) |
ACK slot | 1 | Transmitter sends recessive (1) and any receiver can assert a dominant (0) |
ACK delimiter | 1 | Must be recessive (1) |
End-of-frame (EOF) | 7 | Must be recessive (1) |
Q3: What is Featured of CAN Protocol?
There are few features of can protocol.
- Simple and flexibility in Configuration.
- CAN is Message-Based Protocol.
- Message prioritization feature through identifier selection.
- CAN offer Multi-master Communication.
- Error Detection and Fault Confinement feature.
- Retransmission of the corrupted message automatically when the bus is idle.
Q4: Why Can Is Having 120 Ohms At Each End?
To minimize the reflection reference, to reduce noise. To ensure that reflection does not cause communication failure, the transmission line must be terminated.
Q5: Why CAN Bus uses differential Cable?
CAN Protocol used two-wire twisted-pair cables for CAN-Bus architecture to reduce cross-talk and EMI.
Q6: CAN logic what it follows?
The Can protocol follows the Wired AND logic.
Q7: What is voltage Levels in CAN Protocol?
Bus level according to ISO 11898.
- CANH voltage level is 3.3 Volt
- CANL Voltage Level is 1.5 Volt
Q8: What is Can Arbitration?
CAN Arbitration is nothing but the node trying to take control of the CAN bus. Let us take an example to understand the arbitration in CAN.
Suppose there are two nodes and they start transmitting at the same time both will transmit SOF bit at the same time this will have no effect on arbitration. After that, they start transmitting identifier.
Each node transmits a bit and then observes the bus if the sent data sensed on the bus, then it continues to transmit the identifier. When the nodes observes that the bit it transmitted and the bit it sensed back are not same it knows that a higher priority message is being transmitted on the bus and it starts listening and stops transmitting.
It happens because in case of different bits the node with lower identifier will continue transmitting as it will drive the bus to dominant state (logical 0) while the other node that intends to keep it in default state (recessive state, logical 1), will read back the dominant state on the bus and stop transmitting. This mechanism thus preserves the data as the frame with lower priority is not corrupted due to simultaneous transmissions.
Q9: What is the Basic Principle of CAN Protocol?
CAN protocol is based on Wired AND logic. Wired AND logic means – 0 is dominant. Meaning of Zero dominant is that whenever there is a conflict in two data transmissions, then the sender who is sending 0 will get the priority.
Q10: Why CAN is the message-oriented protocol?
CAN protocol is a message-based protocol, not an address based protocol. This means that messages are not transmitted from one node to another node based on addresses. Embedded in the CAN message itself are the priority and the contents of the data being transmitted. All nodes in the system receive every message transmitted on the bus (and will acknowledge if the message was properly received). It is up to each node in the system to decide whether the message received should be immediately discarded or kept to be processed. A single message can be destined for one particular node to receive or many nodes based on the way the network and system are designed. For example, an automotive airbag sensor can be connected via CAN to a safety system router node only. This router node takes in other safety system information and routes it to all other nodes on the safety system network. Then all the other nodes on the safety system network can receive the latest airbag sensor information from the router at the same time, acknowledge if the message was received properly, and decide whether to utilize this information or discard it.
Q11: What is CSMA/CA and CSMA/CD in CAN Communication?
CSMA stands for Carrier Sense Multiple Access. This concept is used in transmission media access. If multiple ECUs are connected and sharing the same transmission medium to transfer its data. So if they (multiple nodes) start transmission at the same time, then there is the possibility of collision and data corruption.CSMA introduce two concepts CSMA/CA and CSMA/CD to avoid this situation (collision and data corruption).
CSMA/CA:
CSMA/CA is a carrier sense multiple access /collision avoidance. It first checks the state of the medium before sending. It is applicable before starting the transmission. The node having CSMA/CA enabled features first check the transmission medium status before starting transmission. If the BUS is idle(free) then it will start transmission otherwise it will wait for the bus to be idle. In CAN this feature is introduced by the Arbitration concept.
CSMA/CD:
CSMA/CD is a Carrier Sense Multiple Access/Collision Detection. It is applicable when data transmission starts. A Node with CSMA/CD enabled feature detects the collision and stop the further data transmission. It will initiate data re-transmission. In CAN this feature is successfully implemented through Bit Monitoring feature of Transmitter node.
Q12: How many Types of CAN frame exist?
CAN has four frame types:
- Data frame: a frame containing node data for transmission.
- Remote frame: a frame requesting the transmission of a specific identifier.
- Error frame: a frame transmitted by any node detecting an error.
- Overload frame: a frame to inject a delay between data or remote frame
Q13: What is bit stuffing?
CAN use a Non-Return-to-Zero protocol, NRZ-5, with bit stuffing. The idea behind bit stuffing is to provide a guaranteed edge on the signal so the receiver can resynchronize with the transmitter before minor clock discrepancies between the two nodes can cause a problem. With NRZ-5 the transmitter transmits at most five consecutive bits with the same value. After five bits with the same value (zero or one), the transmitter inserts a stuff bit with the opposite state.
Q14: Can Standard CAN and extended CAN coexist in the same network? who will win arbitration if first arbitration field is the same?
As you have seen in CAN frame format in above question only Arbitration field in the extended frame format only differ from the standard CAN means extended CAN architecture designed in such a way that standard and extended CAN coexist on the same network. In extended frame format, the IDE bit distinguish between the standard and extended CAN.
IDE bit is dominant(1) for the Standard frame and recessive for the extended frame.so standard frame will win arbitration if both have the same 1st identifier field(11-bit).
Q15: Why CAN-BUS uses NRZ encoding instead of RZ?
NRZ encoding uses to change Controller digital signal into BUS level.
Q16: What is the CAN Network Topology?
CAN standard supports several topologies. Commonly used topologies are:
- Star Topology.
- Loop Topology.
- Bus Topology.
- Combination.
Q17: Why CAN Bus Topology use terminator resistor at the end?
In a Bus topology, terminator resistor is used whether in CAN or Ethernet or somewhere else to absorb the signal at the end to avoid reflection. Terminator resistor must be equal to the impedance generated because of signal(V/I).In CAN usually 100-120 ohm resistance used at the end of the differential cable.
Q18: Explain the types of CAN error? Which concept is used behind bit error detection?
There are 5 types of error exist in CAN protocol. Two of these works at the bit level, and the other three at the message level.
Cyclic Redundancy Check:
Each message features a 15-bit Cyclic Redundancy Checksum (CRC), and any node that detects a different CRC in the message than what it has calculated itself will signal a CRC Error.
Bit Monitoring:
Each transmitter on the CAN bus monitors (i.e. reads back) the transmitted signal level. If the bit level actually read differs from the one transmitted, a Bit Error is signaled. (No bit error is raised during the arbitration process.)
Bit Stuffing:
When five consecutive bits of the same level have been transmitted by a node, it will add a sixth bit of the opposite level to the outgoing bit-stream. The receivers will remove this extra bit. This is done to avoid excessive DC components on the bus, but it also gives the receivers an extra opportunity to detect errors: if more than five consecutive bits of the same level occurs on the bus, a Stuff Error is signaled.
Acknowledgment Check:
All nodes on the bus that correctly receives a message (regardless of their being “interested” of its contents or not) are expected to send a dominant level in the so-called Acknowledgement Slot in the message. The transmitter will transmit a recessive level here. If the transmitter can’t detect a dominant level in the ACK slot, an Acknowledgement Error is signaled.
Frame check:
Some parts of the CAN message have a fixed format, i.e. the standard defines exactly what levels must occur and when. (Those parts are the CRC Delimiter, ACK Delimiter, End of Frame, and also the Intermission, but there is some extra special error checking rules for that.) If a CAN controller detects an invalid value in one of these fixed fields, a Form Error is signaled.
Q19: What is the application of the CAN Protocol?
There is some application of CAN protocol.
- Passenger vehicles, trucks, buses (gasoline vehicles and electric vehicles).
- Electronic equipment for aviation and navigation.
- Industrial automation and mechanical control.
- Elevators, escalators.
- Building automation.
- Medical instruments and equipment.
Q20: If Master Sends 764 And Slave Sends 744 Which Will Get The Arbitration?
Starts from MSB, the first nibble is same, Master sends 7, slaves also sends 7 the message with more dominant bits will gain the arbitration, lowest the message identifier higher the priority.
Q21: Can Standard CAN and extended CAN coexist in the same network? who will win arbitration if first arbitration field is the same?
As you have seen in CAN frame format in above question only Arbitration field in the extended frame format only differ from the standard CAN means extended CAN architecture designed in such a way that standard and extended CAN coexist on the same network. In extended frame format, the IDE bit distinguish between the standard and extended CAN.
IDE bit is dominant(1) for the Standard frame and recessive for the extended frame.so standard frame will win arbitration if both have the same 1st identifier field(11-bit).
Q22: Can you Use CAN Protocol to transfer Media?
No, It is not capable to transfer media.
Q23: What is the difference between standard CAN and Extended CAN?
- The identifier bit length of standard CAN is 11 and for extended CAN 29.
- IDE bit for standard CAN 0 and for extended CAN 1.
Q24: What Is Meant By Hard Synchronization And Soft Synchronization?
Hard Synchronization to be performed at every edge from the recessive-to-dominant edge during Bus Idle. Additionally, Hard Synchronization is required for each received SOF bit. A SOF bit can be received both during Bus Idle and also during Suspend Transmission and at the end of Interframe Space. Any node disables Hard Synchronization if it samples an edge from recessive to dominant or if it starts to send the dominant SOF bit.
Two types of synchronization are supported:
Hard synchronization is done with a falling edge on the bus while the bus is idle, which is interpreted as a Start of the frame (SOF). It restarts the internal Bit Time Logic.
Soft synchronization is used to lengthen or shorten a bit time while a CAN frame is received.
Q25: Why CAN is asynchronous communication?
Data transmission is not synced with any external clock signal.
Q26: What Are The Functions Of Can Transceiver?
The transceiver provides differential transmit capability to the bus and differential receive capability to the CAN controller. The transceiver provides an advanced interface between the protocol controller and the physical bus in a Controller Area Network (CAN) node.
Typically, each node in a CAN system must have a device to convert the digital signals generated by a CAN controller to signals suitable for transmission over the bus cabling (differential output). It also provides a buffer between the CAN controller and the high-voltage spikes that can be generated on the CAN bus by outside sources (EMI, ESD, electrical transients, etc.).
The can transceiver is a device which detects the signal levels that are used on the CAN bus to the logical signal levels recognized by a microcontroller.
Q27: What happens when two CAN nodes are sending the same identifier at the same time?
The CAN Frame identifier should be unique across the entire network. Assigning the same identifier to two CAN nodes should lead to a configuration error.
Q28: What happens if a node is alone on the bus and tries to transmit?
I believe that the above mentioned CAN Protocol interview questions are helpful. If you want more CAN Protocol interview questions, please comment in the comment box. If you are also looking for the answer for CAN Protocol interview questions, then please post your questions in the comment box.
Recommended Post
- 100 embedded C interview Questions.
- 100 C interview Questions.
- I2C interview Questions
- Interview questions on bitwise operators in C
- C++ Interview Questions.
- 10 questions about dynamic memory allocation.
- File handling in C.
- Pointer in C.
- C format specifiers.
- I2C vs SPI
- Interfacing of EEPROM with 8051 using the I2C protocol
Reference: https://en.wikipedia.org/wiki/CAN_bus