Understanding CAN bit wise arbitration

A free video tutorial from FastBit Embedded Brain Academy
? Amplify Your Embedded Skills ?
Rating: 4.6 out of 5Instructor rating
11 courses
120,547 students
Understanding CAN bit wise arbitration

Learn more from the full course

Mastering Microcontroller: Timers, PWM, CAN, Low Power(MCU2)

Learn STM32 Timers, CAN, RTC, PWM, Low Power embedded systems and program them using STM32 Device HAL APIs step by step.

22:01:21 of on-demand video • Updated December 2023

You will learn from scratch about STM32 Timers : Basic and General Purpose Timers
Understand General purpose timer's Input capture and Output compare unit handling and Exercises
Handling of Timer interrupts : Time base interrupts, capture interrupts, compare interrupts
You will learn from scratch CAN Protocol, CAN Signalling, CAN Transceivers , Bus Access procedures
Understand CAN LOOPBACK mode, SILENT mode and NORMAL mode
Understand about CAN filtering
Learn about CAN interrupts
CAN Peripheral programming using STM32 device HAL drivers
You will master Low power modes of the MCU : SLEEP,STOP and STANDBY
You will understand different power domains of the MCU : VDD domain, 1.2V domain, backup domain
Understand Microcontroller Wakeup Procedures using : RTC, wakeup pins,EXTI,etc.
RTC interrupts and wake up procedures
Mastering Microcontroller Clocks Handling : HSE,HSI,LSE,LSI,PLL
Understand phase locked loop (PLL) programming
Learn PWM mode and Master through step by step code exercises
You should be able to quickly develop applications which involves STM32 Device HAL layer
Hey, welcome back to the lecture. So, in this lecture, let's understand how multiple nodes can access the bus and how the bus access actually serialized. And we are going to understand some animation in order to understand how actually a node wins the arbitration. The CAN communication protocol is a carrier-sense, multiple-access protocol with collision detection and arbitration on message priority. AMP that's stands for Arbitration on message priority. CSMA means that each node on a bus must wait for a prescribed period of inactivity before attempting to send a message. And how that inactivity is sensed, you already know because of the continuous recessive states and the IFS isn't it? That is Inter Frame Spacing. Now, CD+AMP that is arbitration on message priority means that collisions are resolved through the bit-wise arbitration, based on a preprogramed priority of each message in the identifier field of a message. The higher priority identifier always wins the bus access. Now, let's understand a bit-wise arbitration in CAN. OK. So, I'm going to take you through this animation to understand the bit-wise bus arbitration. Now, let's start. OK. So, let's understand the CAN bit-wise bus arbitration between nodes. Now, let's consider three nodes here. NODE-1, NODE-2 and NODE-3. And these are the arbitration IDs of NODE 1, 2 and 3. Now, arbitration ID means, it's a eleven bit identifier, isn't it? So, if you just take a look into these numbers, so which one among these numbers is the lowest one. So, here you can see that 659 is the lowest one, isn't it? So, that means NODE-3 is going to win this arbitration when these three nodes compete for a bus at the same time. OK. So, remember lower the arbitration ID number, higher is the priority. Right. So, let's see how that happens. Now, let's understand with this animation. OK. So, here on the left hand side, you are seeing Node-1, Node-2 and Node-3, all are trying to send a message at the same time and here at the bottom, is the bus state,OK. The resultant bus states CAN High(CANH) and CAN Low(CANL) And here is the identifier field. So, identifier field as I said, is a collection of 11 bit identifier and the RTR bit. Now, as I said, every frame starts with a dominant bit that is SOF. So, all these 3 nodes, they find that the bus is Idle and they try to send a message. So, they first put the SOF bit, isn't it ?. So, that's a dominant bit. OK so, After that they all put the first bit of the arbitration ID. the first MSB, The most significant bit. So, in this case this happens to be 1, 1, 1 in all cases, in all three nodes isn't it? So, after that the bus state in this case becomes recessive because all three nodes have put recessive bit, isn't it? Now, after that again 1 1 1 OK. So, that means the state will be at recessive state and after that they will put, After that they're going to put 0 0 0. That's a dominant state. So, the bus state becomes dominant. Now, after that they all put 0 0 0. OK. And that is actually dominant again. And after that they all put recessive bit. OK. And in this case bus state becomes recessive and after that so, here is a difference. So, here the ID changes for NODE-2 . OK. So, closely observe here, NODE-2 loses arbitration here because it is trying to put the recessive bit OK. But NODE-1 and NODE-3 are putting dominant bit, so that's why NODE-2 goes out of arbitration. So, because the bus state has become dominant. So, the NODE-2 has put recessive but it hears back dominant. Remember, in CAN transceiver what happens? so, this is the design of the CAN transceiver, isn't it?. So,whatever a node puts on the bus, it also hears it back. So, NODE-2 actually put the recessive state. So, the recessive state means, the potential differences between CANH and CANL is zero. But it hears back the potential difference of two. And it understands that it lost the arbitration. So, that's why it will just go to the Listen Only mode. OK. So, it will just sit there and listens. It will not try to compete with NODE-1 and NODE-3. Now the arbitration continues between NODE-1 and NODE-3 now. So next, both actually put the recessive state. So, the bus state becomes recessive and after that again they put the recessive bits. So, the bus state becomes recessive. And after that here you can see that node-1 is trying to put the recessive bit but node-3 put the dominant bit. So hence node-3 wins the arbitration here and node-1 loses the arbitration. So,hence the winner is node-3. OK. So, node-1 actually goes to listen only mode. OK. And after that there are no more devices, so node-3 continues and it then puts its remaining bits of the identifier field and finally the RTR and after that it sends the data. That's how, the arbitration happens and that's how, a node which has the lowest identifier value wins the bus arbitration. That's how the bit-wise arbitration works. So, remember that lower the binary message identifier number that is lower the identify number, the higher is its priority. So, that also means that an identifier consisting entirely of zeroes is the highest priority message on a network, because it hold the bus dominant the longest, isn't it? And also remember that a dominant bit always overrides recessive a bit on a CAN bus. So, that is the reason why node-3 won the arbitration here. OK. So, because it actually overridden all the other recessive states produced by other nodes, isn't it? Great So and the allocation of message priority is up to you, up to the application writer. OK. And remember that all these arbitration will happen automatically by the controller itself. So, you need not to do anything. You just have to allocate the priority values. That's it. I mean the identifier values for different messages. And from the next lecture, let's get started with some programming. So, let's use our CAN peripheral of the STM32 micro-controller to do some applications on CAN. . Okay. Great. So, I'll see you in the next lecture.