When use MCP2515 modules to do CAN BUS project, we need select the library file to suit for the different chip Crystal oscillator, say some use 8 MHZ, and some 16MHZ. There are many library files online, the one attached here was done by Loovee at 2012. The original library has only 16MHZ configuration, like this: case (CAN_500KBPS):
cfg1 = MCP_16MHz_500kBPS_CFG1;
I checked the sketch in that project bound with the library, didn't find anywhere used "16MHZ" even "MHZ", like here : if (CAN_OK == CAN.begin(CAN_500KBPS)), seems the MHZ don't have relationship with the sketch?
If so, the lines I added for the 8MHZ can effect ant thing or just surplus?
The sample of the lines I added: case (CAN_38K4BPS):
cfg1 = MCP_8MHZ_38k4BPS_CFG1;
Please check the library file attached and see if the few lines I added can work? and how the MHZ works ?
Thank you mikb55,
It's true that library file used that sentence dealing with the frequency. I downloaded the library and try to do the compiling , failed with "Error compiling for board Arduino/Genuino Uno", I guess cause of the different version? Seems it will go to far to deal with this error. Because the sketch tested good with the libraries bound that works for 16MHZ chips, and I'll attached the mcp2515 files which included in the bound libraries later.
my questions is in the attached files below, I didn't find the words related to frequency like the "MCP2515::setBitrate(const CAN_SPEED canSpeed, CAN_CLOCK canClock)" kind, actually there are quite many similar MCP2515 libraries don't have it, they works well with 16MHZ chips, is it possible to modify it to suit for 8MHZ chips and how?