CAN bus using MCP25625 and Arduino Uno R4 Minima

I am using an Arduino Uno R4 Minima with a PmodCan module including MCP25625 to send a message via CAN bus. I am also using PCAN view with its original USB adapter to monitor messages on the BUS setting the bitrate to 500KBPS.
I have used exactly the code of: coryjfowler/MCP_CAN_lib.git
Using the CAN-loopback example, i get the message back with no problems.
Using the CAN-send example:

#include <mcp_can.h>
#include <SPI.h>

MCP_CAN CAN0(10);     // Set CS to pin 10

void setup()
{
  Serial.begin(115200);

  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.println("MCP2515 Initialized Successfully!");
  else Serial.println("Error Initializing MCP2515...");

  CAN0.setMode(MCP_NORMAL);   // Change to normal mode to allow messages to be transmitted
}

byte data[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};

void loop()
{
  // send data:  ID = 0x100, Standard CAN Frame, Data length = 8 bytes, 'data' = array of data bytes to send
  byte sndStat = CAN0.sendMsgBuf(0x100, 0, 8, data);
  if(sndStat == CAN_OK){
    Serial.println("Message Sent Successfully!");
  } else {
    Serial.println("Error Sending Message...");
  }
  delay(100);   // send data per 100ms
}

I get "Message Sent Successfully!" in the ouput, but nothing happens on the PCAN view. I have used two termination resistors of 120ohm and common ground. I measured the voltage difference between GND and CAN-L/CAN-H. This gives constant 2.48V for both. The PCAN view adapter works on other devices so the problem is not there.

It seems like the CAN communication is dead. I used another new one. same problem.

Any advice, tips will be appreciated :slight_smile:

Check your crystal; I suspect it might be 8 MHz instead of 16 MHz.

it is the crystal frequency setting!

if your module is the same as this one,

then according to its schematic, the Xtal partnumber is CSTCE20M0V13L99-R0 which is a 20MHz Xtal. You should update that value in your code accordingly.

hope that helps...

Thank you for your reply. I tried 8MHz, 16MHz and 20MHz as well, nothing happened
Is there any method to check if MCP is in Normal mode?

The crystal is the silver component labeled X1. What are the numbers on top? That’s its frequency. This isn’t your module, but it shows what the crystal typically looks like, and these are the ones I use.

I usually build two modules and use the library code to get them running first. This gives me a known good bus. I’m not familiar with the PmodCAN device.

In loopback mode, nothing is placed on the bus; it simply transmits internally to itself. This is useful for debugging, as you mentioned. Once this works, you’ll need to switch to a different mode.