Electronic – arduino – CAN bus bit timing with 16 MHz crystal

arduinocancrystal

I'm trying to receive CAN messages from a radar, whose specification define the following data for bit timing:

CAN baudrate = 250 kBaud
Tseg1 = 8
Tseg2 = 7
Tsjw  = 4
Synchronization on one edge only.

I'm using a 16 MHz crystal in the classic MCP2515 (CAN Controller) + MCP2551 (CAN Transceiver) setup, which I use between the CAN bus and an Arduino Uno, but I believe I'm having some trouble when setting the bit timing configuration in the MCP2515.

This is because using a 16 MHz clock frequency limits the Time Quanta per bit time to be 16. I'm using the MBtime tool to verify the bit timing.

     1 time quanta synchronization segment
   + 1 time quanta propagation delay
   + 8 time quanta phase segment 1
   + 7 time quanta phase segment 2
 ----------------------------
  = 17 time quanta

Which is one more than the required one (16). Being the sync segment is always one, and the propagation segment at least one, how is it possible to make it work with the required parameters?

My ideas are using another crystal, maybe 18 or 20 MHz. (I actually tried with 20 MHz and a four time quanta propagation delay, and it didn't work.)

However, using a CAN-to-USB converter in my PC, I did successfully receive the CAN frames I was expecting from the radar. I set the same settings (Tseg1, Tseg2, SJW, and baud rate). And this converter uses a 16 MHz crystal…

Is there something I'm missing? Should I change the oscillator frequency to another value?

Best Answer

The other side can't tell you how many time quanta to use for various parts of the bit. It can only tell you the bit rate you must adhere to.

Pick a set of time quanta close to what they use but that still comes out to the specified bit rate, and all will be fine. Consider their time quanta "spec" as merely them telling you how their implementation works, not what you have to do.