canChannel on Longan CANBed Arduino unable to find MCP2515

4 次查看(过去 30 天)
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?

回答(1 个)

Manikanta Aditya
Manikanta Aditya 2024-1-12
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.

类别

Help CenterFile Exchange 中查找有关 Run on Target Hardware 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by