david_1234
Posts: 200
Joined: Mon Jan 01, 2018 2:14 pm

using to CanBus on on pi (SPI0 and SPI1)

Tue Nov 19, 2019 4:01 pm

Hello ,
wanted to know how can I read data from 2 canbus interfaces at the same time.

Right now I'm using this configuration for 1 canbus :
/boot/config.txt

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay
and this connections

Code: Select all

GPIO                CAN
HEADR   SIGNAL     MODULE
PIN      NAME  --- SIGNAL
#02       5V --- VCC
#06        GND --- GND
#19       MOSI --- SI
#21       MISO --- SO
#23       SCLK --- SCK/CLK
#24   SPI0.CE0 --- CS
#32     GPIO12 --- INT
and it's working without any problems

I want to use another one (at the same time) and I saw there is a SPI1 interface on th PI.

If I do the following , will it work?

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=mcp2515-can1,oscillator=8000000,interrupt=16 ///adding only this line 
dtoverlay=spi-bcm2835-overlay

Code: Select all

GPIO                CAN
HEADR   SIGNAL     MODULE
PIN      NAME  --- SIGNAL
#02       5V --- VCC
#06        GND --- GND
#38       MOSI --- SI
#35       MISO --- SO
#40       SCLK --- SCK/CLK
#26   SPI0.CE0 --- CS
#36     GPIO16 --- INT
Or do I need to configurate something else elsewhere?


Thanks ,

david_1234
Posts: 200
Joined: Mon Jan 01, 2018 2:14 pm

Re: using to CanBus on on pi (SPI0 and SPI1)

Wed Nov 20, 2019 3:33 pm

I saw on the internet that I can do this using a special card
https://copperhilltech.com/content/PICAN2DUOUGB.pdf

but can't I do the same using my own setting?

I have try to add this lines in the boot/config.txt

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=12
dtoverlay=mcp2515-can1-overlay,oscillator=16000000,interrupt=16
dtoverlay=spi-bcm2835-overlay
but now nothing is working
it doens't recognaize can0 anymore
I have added this line then reboot the pi


then I saw I need to enable spi1by adding this line in the boot/config.txt

Code: Select all

dtoverlay=spi1-3cs
so I have add this and now I can see:

Code: Select all

ls /sys/bus/spi/devices/spi
spi0.0/ spi0.1/ spi1.0/ spi1.1/ spi1.2/ 

but still it doesn't work

what am I missing\doing wrong?

Thanks ,

Return to “General discussion”