Skip to content

CAN Shield Configuration

Tobias Jaehnel edited this page May 31, 2023 · 5 revisions

In order to configure the SPI controller of the Raspberry Pi to make it communicate with the CAN-Shield, you need to add a few lines to config.txt which is available on the boot partition of the RaspberryPi OS / CarSimulator Image. This is different for each CAN shield:

CAN-Shield lines to be added to config.txt Notes
PiCAN 2PiCAN 2
dtparam=spi=ondtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25dtoverlay=spi-bcm2835-overlay
PiCAN 2 DUOPiCAN 2 DUO
dtparam=spi=ondtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24dtoverlay=spi-bcm2835-overlay
RS485 CAN HATRS485 CAN HAT
dtparam=spi=ondtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25,spimaxfrequency=1000000
This CAN-Shield has a 8MHz clock only. During high bus activity this can lead to problems.We especially experienced this during flashing where frames got lost.
PiCAN 2PiCAN 3 dtparam=spi=ondtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=500000dtoverlay=spi-bcm2835-overlay PICAN3_UGA_10.pdfNote: spimaxfrequency needs to be set, which is not mentioned in the User Guide, in case the shield is used on RPi4, because the SPI bus has a higher frequency by default than the CAN controller can handle. Maybe higher freq is possible. If it's too high, the controller driver can't be loaded during bootup and there is an error message in dmesg visible.See this link for more details.

Clone this wiki locally