The current page describes different posibilities of connecting a MCP2515 with TJA1050 to a set of board (e.g., Arduino, Raspberry Pis).
- CAN-Bus with Raspberry Pi: HowTo/Quickstart MCP2515 Kernel 4.4.x+
- raspberrypi.org: CAN bus on raspberry pi with MCP2515
- How to Connect Raspberry Pi to CAN Bus
- Say it with a CAN Bus and a Raspberry Pi
- CAN utils for linux command line
- Python module for CAN communication
Pin | UNO | MCP2515 |
---|---|---|
INT | 2 | INT |
MISO | 12 | SO |
MOSI | 11 | SI |
SCK | 13 | SCK |
SS | 10 | CS |
Pin | MEGA | MCP2515 |
---|---|---|
INT | 2 | INT |
MISO | 50 | SO |
MOSI | 51 | SI |
SCK | 52 | SCK |
SS | 53 | CS |
To use a MCP2515 CAN controller with TJA1050 transciever this modification must be done.
It is necessary to modify the CAN-module because it has only one VCC pin, but the MCP2515 must be powered from 3v3 and the TJA1050 CAN transceiver must be powered from 5v. Powering both chips from 5V would work, but then a level-shifter for the SPI would be needed. The Pis GPIO pins are NOT 5V tolerant. Cut a trace on the PCB and soldered a pin onto the trace to deliver 5V only to the TJA1050. Be sure to cut the trace before the capacitor (otherwise if there is no capacitor, add one (about 100nF maybe)).
RPi | MCP2515+TJA1050 |
---|---|
22 | INT |
21 | SO |
19 | SI |
23 | SCK |
24 | CS |
6 | GND |
2 | TJA1050 VCC 5v |
1 | MCP2515 VCC 3v3 |
Boot config:
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi1-1cs
TODO
RPi | MCP2515+TJA1050 |
---|---|
37 | INT |
35 | SO |
38 | SI |
40 | SCK |
36 | CS |
39 | GND |
4 | TJA1050 VCC 5v |
1 | MCP2515 VCC 3v3 |
Boot config:
# Enable SPI
dtparam=spi=on
# CAN Mcp2515 interface
dtoverlay=spi1-1cs,cs0_pin=16,cs0_spidev=off
dtoverlay=mcp2515-can2,oscillator=8000000,interrupt=26
# TPM SLB9670
dtoverlay=tpm
Append to /etc/network/interfaces the ip link command that raises the interface.
Example 1:
auto can0
iface can0 can static
bitrate 250000
Example 2:
auto can1
iface can1 inet manual
pre-up /sbin/ip link set can1 type can bitrate 500000 loopback off restart-ms 100
up /sbin/ifconfig can1 up
down /sbin/ifconfig can1 down