Help with CANBUS

Thread Starter

bolshoibooze

Joined Mar 11, 2021
1
I am pretty new in microcontroller programming complete noob actually, atm I am trying to figure out CANBUS.
My question is microcontrollers are generally 32 bits right? But in CANBUS protocol you sometimes use nearly 120 bits length for sending a single message(Start, identifier, data, end of frame, etc.). How is this happening can someone explain me please?

Thanks
 

Papabravo

Joined Feb 24, 2006
16,814
The overhead of bits in a frame allows certain desirable features. Among those features are:
  1. Bus access arbitration
  2. Error detection
  3. Peer to peer connections
The actual number of overhead bits depends on identifier length and bit stuffing. It is actually fairly efficient use of bandwidth, especially with bus arbitration.
 

Ian0

Joined Aug 7, 2020
3,249
There are 64 bits of data in a CAN frame, and 11 or 27 bits of "message ID". The CAN peripheral puts all this together into the final message, which also includes error checking and a few other things.
The processor sees the peripheral as a series of 16-bit or 32-bit registers, four 16-bit registers contain the data that is to be sent or received. Another register contains the message ID, the baud rate and the number of bits of data in the message.
Cleverer CAN peripherals can contain up to 20 different messages at any one time, and further registers allow the CPU to select which message is being read or transmitted.
The peripheral does all the hard work, so the CPU doesn't have to. It deals with data collisions, errors, re-transmissions if the data is not received at the other end. It looks more complicated than RS485, but the software overhead is much lower.
If you want to be absolutely sure that your data has arrived where you sent it, use CAN!
(but it will probably take you a week to learn how to use it)
 
Top