107-systems / 107-Arduino-MCP2515

Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames.

Home Page:https://107-systems.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug Report]Try to use it on esp32c3 but not work

fgy58963 opened this issue Β· comments

πŸ› Bug Report

Describe the bug

Datasheet: Esp32c3 datasheet
Hi, I am trying use this lib on esp32c3 on arduino which has 3 spi.spi 2 is for normal use. By compare de loopback example. I am define cs pin 10, int pin 3. sck pin 6, mosi pin 7, miso pin 2.
replace SPI.begin() to SPI.begin(6,2,7,-1);
Everything looks working but cannot call int function onReceiveBufferFull.

I am adding this code and it shows ok

if(!mcp2515.transmit(frame.id, frame.data, frame.len)) {
                          Serial.println("ERROR TX");
                      }else{
                          Serial.println("OK TX");
                      }

I tried other mcp2515 library and get the same result. I am also tried anoter pin define. becuz esp32c3 said spi2 could be any pins. But nothing works.

Minimum example code to replicate the bug

void setup()
{
    pinMode (12, OUTPUT) ;
    digitalWrite (12, HIGH) ;
//--- Start serial
    Serial.begin (115200) ;
    while (!Serial);

    /* Setup SPI access */
    SPI.begin(6,2,7,-1);
    pinMode(MKRCAN_MCP2515_CS_PIN, OUTPUT);
    digitalWrite(MKRCAN_MCP2515_CS_PIN, HIGH);

    /* Attach interrupt handler to register MCP2515 signaled by taking INT low */
    pinMode(MKRCAN_MCP2515_INT_PIN, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(MKRCAN_MCP2515_INT_PIN), [](){ mcp2515.onExternalEventHandler(); }, LOW);

    mcp2515.begin();
    mcp2515.setBitRate(CanBitRate::BR_250kBPS_16MHZ); // CAN bit rate and MCP2515 clock speed
    mcp2515.setLoopbackMode();

    std::for_each(CAN_TEST_FRAME_ARRAY.cbegin(),
                  CAN_TEST_FRAME_ARRAY.cend(),
                  [](sCanTestFrame const frame)
                  {
                      if(!mcp2515.transmit(frame.id, frame.data, frame.len)) {
                          Serial.println("ERROR TX");
                      }else{
                          Serial.println("OK TX");
                      }
                      delay(1000);
                  });
}

the terminal just shows:
OK TX
OK TX
OK TX
OK TX
OK TX
OK TX
OK TX

Minimum configuration to replicate the bug
Please provide the configuration data used to build Snowfox:

  • Build Toolchain:Arduino IDE 2.0 and PlatformIO+CLion, both tried.
  • Arduino Core: framework-arduinoespressif32 @ 3.20005.220925 (2.0.5)
  • Library Version (of all involved libraries): 1.3.5