Why does the CAN Receive block from Raspberry Pi support package not work with PiCAN 2 shield in R2020a and earlier?

조회 수: 4 (최근 30일)
I am using the PiCAN 2 CAN bus shield for Raspberry Pi. In my Simulink model, I inserted a CAN Receive block from the Simulink Support Package for Raspberry Pi. In the model's Configuration Parameters, I set the Interrupt Pin to 25. However, I am unable to observe any CAN bus signal.
When I use other tools such as Vector CANoe, I am able to observe the CAN bus signal. Why does the CAN Receive block from Raspberry Pi support package not work with PiCAN 2 shield?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2021년 10월 13일
편집: MathWorks Support Team 2021년 10월 13일
Raspberry Pi CAN blocks are designed to work with MCP2515 based CAN shields such as the PiCAN2. For the PiCAN2 shield, however, the interrupt GPIO Pin may not be saved correctly in the code from the model's Configuration Parameters when using MATLAB R2020a or earlier. As a result, the interrupts triggered by the CAN shield are ignored.
To work around the issue, follow the below steps:
1. Execute the following command at the MATLAB Command Prompt:
>> cd(fullfile(codertarget.raspi.internal.getSpPkgRootDir,'include'))
2. Update the file “MW_MCP2515_CAN.h” in the above directory with the following changes at line 33. Replace
#define INTERRUPT_PIN 12
with
#define INTERRUPT_PIN (MW_CAN_INTERRUPTPIN)
3. Restart MATLAB and change the interruption pin accordingly.
  댓글 수: 1
Reeno Joseph
Reeno Joseph 2020년 4월 22일
Please make sure that in the model config set the interrup pin is properly set.
For PiCAN2 the interrupt pin is 25.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Raspberry Pi Hardware에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by