Sparkfun CAN shield canbus.h file - configuration question

Hi all, I’m trying to configure the canbus.h file for use with the Sparkfun Arduino CAN shield.

There are existing definitions for three CAN speeds, I need to add a fourth for 1MBit. I can’t find any explanation for what these numbers (7, 3, 1) after each speed definition mean, and therefore don’t know how to calculate the correct number to use for my 1 MBit entry. Any ideas please? thank you

(snippet from the top of canbus.h) :?:

#define CANSPEED_125 7 // CAN speed at 125 kbps

#define CANSPEED_250 3 // CAN speed at 250 kbps

#define CANSPEED_500 1 // CAN speed at 500 kbps

#define CANSPEED_1000 ? // Added CAN speed at 1 mbps

//what number needs to be set after the definition?

I found this one https://github.com/kahiroka/slcanuino/b … s/Canbus.h that appears to use ‘0’…maybe give that a try?

Those numbers set the Baud Rate Prescalar bits in the MCP2515 Configuration 1 (CNF1) register. I recommend grabbing the datasheet for that chip and reading through it. There are many other configuration options that determine how bits are generated and received, but if you’re just wanting to change speed, 0 should do the trick for you.