MCP2515 CAN bus user overlay


BertHav
 Share

3 3

Recommended Posts

Hereby a tutorial to connect an MCP2515 based CAN bus interface to an OrangePi 3 running successfull with Buster minimal nightly with 5.3 kernel. It uses the attached user overlay only and doesn’t need any other overlay.

 

Connections
CAN module

OPi3

26 pin header

Raspberry

CAN interface

40 pin header
Vcc 3.3 CON12-P01 1
Gnd CON12-P06 6
MOSI CON12-P19 19
MISO CON12-P21 21
CLK CON12-P23 23
CS CON12-P24 24
INT CON12-P26 22

Optional 5V for

Transceiver

on cheap

Chinese modules

CON12-P02

Not used

when

equiped

with a

3.3V transceiver

 

Add the attached overlay with the command:

sudo armbian-add-overlay spi-h6-mcp2515.dts

The file /boot/armbianEnv.txt now contains a line:

user_overlays=spi-h6-mcp2515

Reboot the OrangePi 3

Check if the MCP2515 is recognized:

pi@orangepi3:~$ dmesg | grep mcp

If properly connected it should return a line containing:

mcp251x spi1.0 can0: MCP2515 successfully initialized.

As stated a can0 interface should be generated check it with:

pi@orangepi3:~$ sudo ifconfig -a

 

 

Bring up the network:

sudo ip link set can0 up type can bitrate 250000

Check if the interrupt is hooked:

cat /proc/interrupts

should return a line like this

46:          1          0          0          0  sunxi_pio_edge   8 Edge      mcp251x

 

Check for traffic on the CAN bus with candump from can-utils  (sudo apt-get install can-utils)

candump can0

 

spi-h6-mcp2515.dts

Link to post
Share on other sites

Donate and support the project!

Searching the forum will give an explanation, sometimes Google is your best friend.....

For short, replace  "sudo armbian-add-overlay spi-h6-mcp2515.dts" with the following commands:

 dtc -@ -q -I dts -O dtb -o spi-h6-mcp2515.dtbo spi-h6-mcp2515.dts

 sudo nano /boot/armbianEnv.txt
          insert the line: user_overlays=spi-h6-mcp2515
          write and exit nano

sudo mkdir -p /boot/overlay-user

sudo cp spi-h6-mcp2515.dtbo /boot/overlay-user/spi-h6-mcp2515.dtbo

Reboot the OrangePi 3 and continue with check if the MCP2515 is recognized

Link to post
Share on other sites

Hello, i work on  Lime-a64 board (olimex).

 

Based on this topic and some other around, i wrote the overlay attached.

The module i used is use on this topic for the raspberry : tutorial raspberryi.

 

The pinout:

| Lime-A64  | UEXT Nb |   Function   | Output | Module  |
| --------- | ------- | ------------ | ------ | ------- |
| +3.3      | 1       |              | VCC    | 7       |
| GND       | 2       |              | GND    | 6       |
| PH4       | 3       | UART3TX      |        |         |
| PH5       | 4       | UART3RX      |        |         |
| PH2       | 5       | TWI1-SCK     | INT    | 1       |
| PH3       | 6       | TWI1-SDA     |        |         |
| PC1       | 7       | SPI_MISO     | SO     | 4       |
| PC0       | 8       | SPI_MOSI     | SI     | 3       |
| PC2       | 9       | SPI_CLK      | SCK    | 2       |
| PC3       | 10      | SPI_CS       | CS     | 5       |

 

The mcp seem will initialized and i can up the interfaces. however, i am not sure interrupts works.

This line seem wrong : 

 interrupts = <0 194 2>; /* PH2 IRQ_TYPE_EDGE_FALLING */

 

Someone know how to correctly set the line with the Allwinner A64,  PH2 pin ?

 

 

spi-a64-mcp2515.dts

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

3 3