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.
Configuration:
- SJW=1
- BRP=1
- PSHEG1=7
- PSHEG2=5
- PROPSEG=7
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.