constant INT LED -> CAN_MSGAVAIL

Dear members,

I’m new here and currently working with Arduino and a CAN-BUS shield. Idea is to simulate some (CAN) signals from missing modules to make a car working correctly (missing speed signal, etc).

I made a new sketch to check if all is working.

[code] #include <mcp_can.h>
#include <SPI.h>

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

  unsigned char flagRecv = 0;
  unsigned char len = 0;
  unsigned char buf[8];
  char str[20];
 
int can_cycle = 0;
int LEDPIN = 13;


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

    Serial.print("status_1= ");
    //Serial.println(CAN.checkReceive());
   
    while (CAN_OK != CAN.begin(CAN_500KBPS))              // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println(" Init CAN BUS Shield again");
        delay(100);
    }
    Serial.println("CAN BUS Shield init ok!");

    pinMode(LEDPIN, OUTPUT);

    attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt
   
    Serial.print("status_2= ");
    Serial.println(CAN.checkReceive());
}

void MCP2515_ISR()
{
    flagRecv = 1;
}


void loop()
{

// Dynamic messages
unsigned char x135[5] = {69, 65, 57, 191, 255};                        // CAS Key status

     Serial.print("status_3= ");
    Serial.println(CAN.checkReceive());
   
if (CAN_NOMSG == CAN.checkReceive())
{   
    CAN.sendMsgBuf(0x135, 0, 5, x135);
}

        Serial.print("status_4= ");
    Serial.println(CAN.checkReceive());
    delay(100);                       // send data per 100ms

        Serial.print("status_5= ");
    Serial.println(CAN.checkReceive());

 if(flagRecv)
 {
 
          flagRecv = 0;                // clear flag
          CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
 
          Serial.println("\r\n------------------------------------------------------------------");
          Serial.print("Get Data From id: ");
          Serial.println(CAN.getCanId());
          for(int i = 0; i<len; i++)    // print the data
          {
              Serial.print("0x");
              Serial.print(buf, HEX);
              Serial.print("\t");
          }
          Serial.println();
 
     
       
    Serial.println("status_6= ");
    Serial.println(CAN.checkReceive());
}
}[/code]

Once it runs the sketch with serial monitor, it shows status = 4 (CAN_NOMSG). Once I connect a CAN-BUS interface and send static messages at 1000 ms the INT LED blinks, no problems there. Also the status shows 3 and 4 (CAN_MSGAVAIL & CAN_NOMSG) and displays the ID and message. No problems. Once I set the cycle time of the static messages to 800 or lower, the INT LED is permanently ON even if I stop sending messages and the status in serial monitor is kept at 3 (CAN_MSGAVAIL).

The same happends when I connect the shield to an existing car CAN network.

I have read the manual slightly of the MCP2515, and it indicates that the INT status needs to be cleared. But why does it work correctly on lower speeds and not on higher speeds?

Best regards,
Tom