Hi,
I'm using the autowp-mcp2515 and Arduino_PortentaBreakout library for a CAN BUS interface using the Arduino Portenta H7 Lite.
#include <SPI.h>
#include <mcp2515.h>
#include <Arduino_PortentaBreakout.h>
struct can_frame canMsg;
MCP2515 mcp2515(SPI1_CS);
void setup() {
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_125KBPS);
mcp2515.setNormalMode();
Serial.println("------- CAN Read ----------");
Serial.println("ID DLC DATA");
}
void loop() {
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
Serial.print(canMsg.can_id, HEX); // print ID
Serial.print(" ");
Serial.print(canMsg.can_dlc, HEX); // print DLC
Serial.print(" ");
for (int i = 0; i<canMsg.can_dlc; i++) { // print the data
Serial.print(canMsg.data[i],HEX);
Serial.print(" ");
}
Serial.println();
}
}
When I upload this sketch, the Arduino Portenta H7 Lite immediatly goes into SOS mode (4X blink red LED short, 4X blink red LED long) when going through line 5&6 of the sketch (creating the mcp2515 object).
What could be the problem here?