Skip to content

Repetitive un-commanded CAN messages and Init sequence issue #93

@lolachampcar

Description

@lolachampcar

First ever issue report so please forgive me if I am not following proper procedure.

CANIPULATOR board, Arduino IDE, ESP32C6 Dev Module board choice

I am testing dual TWI (CAN) functionality by mirroring one bus to the other. I've found that changing the input CAN message ID causes the code to generate un-commanded CAN messages. Please see the attached screenshots

This is using an ID of 0x007 23 frames sent and 46 frames captured (the 23 sent to CAN0 and the 23 echoed back on CAN1)
Image

Simply change the transmit id from 0x007 to 0x008 and this happens (8 sent and 66663 received)
Image

I've tried to limit the code to the least elements necessary to limit possible causes.

#define CAN0_SHUTDOWN 3
#define CAN0_STANDBY 0

#define CAN1_SHUTDOWN 2
#define CAN1_STANDBY 1

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

FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(50);  // Start with low brightness

// setup CAN0 pins
pinMode(CAN0_SHUTDOWN, OUTPUT);
pinMode(CAN0_STANDBY, OUTPUT);
// enable CAN0 transceiver
digitalWrite(CAN0_SHUTDOWN, LOW);
digitalWrite(CAN0_STANDBY, LOW);

// setup CAN1 pins
pinMode(CAN1_SHUTDOWN, OUTPUT);
pinMode(CAN1_STANDBY, OUTPUT);
//enable CAN1 transceiver
digitalWrite(CAN1_SHUTDOWN, LOW);
digitalWrite(CAN1_STANDBY, LOW);

// setup CAN pins and speed

CAN1.setCANPins(GPIO_NUM_18, GPIO_NUM_19);
CAN1.begin(500000);
CAN1.watchFor();
CAN0.setCANPins(GPIO_NUM_16, GPIO_NUM_17);
CAN0.begin(500000);
CAN0.watchFor();
// CAN0.debuggingMode = true;
// CAN1.debuggingMode = true;

fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.show();
delay(1000);

// Turn all LEDs off
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
Serial.println("Exiting Setup");

}

auto lastCan0Frame = 0;
auto lastCan1Frame = 0;

void loop() {
CAN_FRAME frame0;

if (CAN0.available() && CAN0.read(frame0)) {
// print out bus and frame
//printFrame(&frame0, 0);
CAN1.sendFrame(frame0);
// Serial.println("Frame sent from CAN0 to CAN1");
// lastCan0Frame = millis();
// fill_solid(leds, NUM_LEDS, CRGB::Red);
// FastLED.show();
}

CAN_FRAME frame1;

if (CAN1.available() && CAN1.read(frame1)) {
// print out bus and frame
// printFrame(&frame1, 1);
CAN0.sendFrame(frame1);
// Serial.println("Frame sent from CAN1 to CAN0");
// lastCan1Frame = millis();
// fill_solid(leds, NUM_LEDS, CRGB::Blue);
// FastLED.show();

}

}

Any ideas as to what I might be doing wrong in my calls to the library?

In addition, I learned that initializing the TWI modules CAN0 then CAN1 caused CAN0 to cease being able to transmit and receive while causing the above code to echo CAN1 receptions back to CAN1 (as opposed to CAN0).

Thank you for any comments and/or help. Bill

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions