chmdebeer
Posts: 1
Joined: Wed Jul 26, 2017 5:05 am

(Solved) can bus with mcp2515 on pi v3

Tue Aug 15, 2017 5:28 am

It took me weeks to get the can bus working with MCP2515 on the pi v3. You will find MANY threads mentioning this problem:

Code: Select all

Cannot find device "can0"
In response to

Code: Select all

sudo /sbin/ip link set can0 up type can bitrate 500000
Looking is dmesg you will see:

Code: Select all

mcp251x spi0.0: Cannot initialize MCP2515. Wrong wiring?
mcp251x spi0.0: Probe failed, err=19
This happens when the SPI speed is too high for the MCP2515. On the new pi boards the default SPI speed is 10MHz. Slow it down by changing the overlay configuration.

Code: Select all

sudo vi /boot/config.txt
Then change the lines to:

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=500000
dtoverlay=spi0-hw-cs
I suggest starting really slow, 500kHz shown above. Then work your way up until the MCP2515 fails to respond.

For reference, I am running:

Code: Select all

uname -a
Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

Return to “Interfacing (DSI, CSI, I2C, etc.)”