I am running a PIC18F with an HS oscillator of 40 MHz. The hardware is not the problem and all the connections are properly done. The microcontroller is connected to the MCP2510 (with a parallel cut crystal of 20 MHz) via SPI, so I can interact with the CAN bus line through the MCP2551. I have done the configuration to run at 1 Mbit/s, but it is not working because it is running at 500 kbit/s. The CAN bus configuration is correctly done, but it is not running as fast via SPI as I want.


  • SJW=1
  • BRP=1
  • PSHEG1=7
  • PSHEG2=5

The initialization of the SPICAN bus is done as the MikroElektronika CANSPI library.

I have been working on this a lot of time, and I think that the SPI initialization is the problem. As far as I know a 20 MHz crystal is enough to run the MCP2510 at 1 Mbit/s. Where is the problem? Is the SPI module running slower than I want?

I do not know why, but when I change the speed it always divide it by two.

  • \$\begingroup\$ What is an "HS oscillator"? High-speed oscillator? Or with very fast flanks (no matter the actual frequency)? \$\endgroup\$ Jul 5, 2017 at 21:18

1 Answer 1


When troubleshooting serial buses, an oscilloscope is invaluable. If you don't have a lab grade instrument, pick up a simple, inexpensive USB scope. There are also inexpensive CAN/SPI diagnostic modules available in USB format.

It is always a good practice when troubleshooting serial bus problems, to significantly reduce the bus speed. This not only makes it easier to spot problems with a scope, but the effect of parasitics is dramatically reduced. Once you getting it working at low speed, you can raise the frequency to observe and isolate any changes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.