I’m working with an MCP2515 CAN module (16 MHz crystal) connected to an Arduino using the mcp_can library by Cory Fowler.
- Baud rate: 250 kbps
- Bus termination: 120 Ω resistor at each end
- With PCAN, I can send/receive messages successfully.
- With CANoe 15/16, I see this error when Arduino transmits:
CAN Error TxErr
ECC: 110000000xxxxx
Code: Bit Error
Bit Position: 0
ID: 0x00
DLC: 0
Arduino code
#include <SPI.h>
#include <mcp_can.h>
const int CS_PIN = 10;
const int RELAY_PIN = 7;
MCP_CAN CAN0(CS_PIN);
void setup() {
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
Serial.begin(115200);
while (!Serial);
if (CAN0.begin(MCP_ANY, CAN_250KBPS, MCP_16MHZ) == CAN_OK) {
Serial.println("MCP2515 Init OK!");
} else {
Serial.println("MCP2515 Init FAILED");
while (1);
}
CAN0.setMode(MCP_NORMAL);
delay(50);
Serial.println("Ready to receive CAN messages.");
}
void loop() {
long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
if (CAN0.checkReceive() == CAN_MSGAVAIL) {
CAN0.readMsgBuf(&rxId, &len, rxBuf);
Serial.print("Received ID: 0x");
Serial.print(rxId, HEX);
Serial.print(" Data=");
for (byte i = 0; i < len; i++) {
if (rxBuf[i] < 0x10) Serial.print("0");
Serial.print(rxBuf[i], HEX);
Serial.print(" ");
}
Serial.println();
if (rxId == 0x200 && len > 0) {
if (rxBuf[0] == 0x01) {
digitalWrite(RELAY_PIN, HIGH); // turn relay ON
Serial.println("Relay ON");
} else if (rxBuf[0] == 0x00) {
digitalWrite(RELAY_PIN, LOW); // turn relay OFF
Serial.println("Relay OFF");
}
}
}
}
It looks like CANoe does not ACK my Arduino messages.
Things I’ve checked:
- MCP2515 runs in Normal mode (verified via CANSTAT register).
- With MCP loopback mode, messages are fine.
- Arduino → PCAN communication works both ways.
- In CANoe, baud is set to **250 kbps, 16 MHz clock.
Questions:
- Could this be a bit timing mismatch between MCP2515 and CANoe?
- Is there anything in CANoe configuration (e.g. “Use Edge filter”, CAN FD options) that I should disable to match a classic CAN controller?
Any advice on resolving this would be great
Thanks!