canChannel on Longan CANBed Arduino unable to find MCP2515

4 views (last 30 days)
I have a Longan CANBed V1 (https://docs.longan-labs.cc/1030008/), which is an Arduino Leonardo and MCP2515 on the same board. It works fine with the Arduino IDE using the Seeed Studio CAN bus library, with the CS pin set to 17.
I am trying to set it up in MATLAB using the following code:
a = arduino('com5', 'leonardo', 'Libraries', 'CAN');
tx = canChannel(a, 'MCP2515', 'A4', 'D2');
However, this gives the following error: "Unable to find MCP2515. Check if the chip select pin and the interrupt pins are correctly connected."
I have tried all combinations of chip select and interrupt pins, but none seem to work. Any advice?

Answers (1)

Manikanta Aditya
Manikanta Aditya on 12 Jan 2024
Hi,
From the error message, it is seen that the MATLAB suggests that it's unable to find the MCP2515 chip. This could be due to incorrect pin assignments.
According to the (Longon documentation https://www.longan-labs.cc/1030008.html ) the board uses the MCP2515 as its CAN controller and the MCP2551 as its CAN receiver. However, the specific pin assignments for the MCP2515 aren’t mentioned in the documentation.
In your MATLAB code, you’re setting the Chip Select (CS) pin to ‘A4’ and the Interrupt pin to ‘D2’. However, you mentioned that the CS pin is set to 17 when using the Arduino IDE with the Seeed Studio CAN bus library. This discrepancy might be causing the issue.
If this doesn’t solve the issue, I recommend checking the Longan Labs documentation or their support for specific pin assignments for the MCP2515 on the CANBed V1.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!