tonton81 / FlexCAN_T4

FlexCAN (CAN 2.0 / CANFD) Library for Teensy 3.x and 4.0
https://forum.pjrc.com/threads/56035-FlexCAN_T4-FlexCAN-for-Teensy-4
MIT License
196 stars 66 forks source link

can2.setClock() resets baud rate of can1 #76

Open piranha771 opened 7 months ago

piranha771 commented 7 months ago

What did I do

I use 2 CAN objects in my firmware. can1 and can2:

    // Setup
    can1.begin();
    can1.setClock(CLK_60MHz);
    can1.setBaudRate(125'000);
    can1.setMaxMB(16);
    can1.enableFIFO();
    can1.enableFIFOInterrupt();
    can1.onReceive(onCan1Receive);

    can2.begin();
    can2.setClock(CLK_60MHz);
    can2.setBaudRate(250'000);
    can2.setMaxMB(16);
    can2.enableFIFO();
    can2.enableFIFOInterrupt();
    can2.onReceive(onCan2Receive);

Expected behavior

After setup: can1.getBaudRate() result is 125'000

Observed behavior

After setup: can1.getBaudRate() result is 0

Additional information:

when a debug print is placed in the method setBaudRate you can see that this method is called multiple times with 0 when on any canbus object .setClock() is called.