Error in programming MCP-2515 -send mode

I am having trouble with getting the MCP-2515 to send data. I had it working but now it does not appear to be sending messages.

 #include <mcp_can.h>
#include <SPI.h>
#define CAN0_INT 18  
MCP_CAN CAN0(10);     // Set CS to pin 10

void setup()
{
  Serial.begin(115200);
delay(3000);
  // 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
  //CAN0.abortTX();
  pinMode(CAN0_INT, INPUT);  
  delay(1000);
}

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(1000);   // send data per 100ms
}

/*********************************************************************************************************
  END FILE
*********************************************************************************************************/> 

In the monitor I get --08:01:19.774 -> Entering Configuration Mode Successful!
08:01:19.774 -> Setting Baudrate Successful!
08:01:19.774 -> MCP2515 Initialized Successfully!
08:01:20.754 -> Error Sending Message...
08:01:21.758 -> Error Sending Message...

If I uncomment the line -- //CAN0.abortTX(); and run the program
I get the following in the monitor but I don't think the messages are actually being sent --07:55:22.266 -> Entering Configuration Mode Successful!
07:55:22.266 -> Setting Baudrate Successful!
07:55:22.341 -> MCP2515 Initialized Successfully!
07:55:23.311 -> Message Sent Successfully!
07:55:24.311 -> Message Sent Successfully!

I have used a new MCP-2515 board and the same thing happens. I think it is a software problem. I must have corrupted something. There does not seem to be a reset function to correct this. My board has an 8.000 on the crystal and I tried the MCP_8MHZ in the 'begin' function but that did not help.

Any Thoughts would be appreciated.

Welcome!

I’m not sure I can help without seeing exactly what you have in front of you. To assist you effectively, please provide the following:
1. Annotated Schematic: Post a detailed schematic of your setup exactly as you have it wired, showing all connections, including power, ground, and power supplies.
2. Technical Information Links: For all hardware devices in your circuit, provide links to technical information. Be aware that many items in the Arduino/Pi world may have the same name but function differently. Links to sales pages like Amazon often lack the necessary technical details, so ensure the links you provide contain the correct specifications and data sheets.
3. Be Thorough: It’s your problem, and the more precise and detailed information you provide, the faster we can help you troubleshoot. This saves everyone time and helps us give you the best possible assistance.

Thanks for the quick reply. Schematic --https://docs.arduino.cc/resources/schematics/A000067-schematics.pdf
I am unable to insert link to Amazon for the MCP-2515



Schematic says "SI to MEGA SPI pin 5". It should be pin 4 and the green wire is correctly connected to pin 4.
Your sketch closely resembles to the library example CAN_send.ino but not exactly. Why ?

Without that information this will just be a guessing game I do not want to burn time on. Show both CAN nodes, if you only have one you are getting the correct results. Be sure to show buss termination and length (at least a meter I hope).

Also explain how you will determine if it does or does not send a message.