I received the MCP2562-E/SN transceivers used on skpang's board last week and have spent a fair amount of time experimenting. So far the MCP2562-E/SN acts identically to the other three chips I tried before.
Just for recap: using FIFO interrupt callback on CAN2 to transmit sequentially on CAN1 eventually gets stuck indefinitely with a message "transmitting" in the mailbox.
The original setup included a custom PCB and recorded messages being played back onto CAN2 with a Vector VN1610. Item by item I simplified this setup, but never saw any improvement.
The current setup has moved to a breadboard and involves 2x Teensy_4.0:
My hope is that you would be able to confirm this "lockup" behavior with 1x PJRC breakout and 1x skpang breakout.
Teensy #1 code:
Teensy #2 code:
Typical serial output on from Teensy #2:
Thanks, Mike
Just for recap: using FIFO interrupt callback on CAN2 to transmit sequentially on CAN1 eventually gets stuck indefinitely with a message "transmitting" in the mailbox.
The original setup included a custom PCB and recorded messages being played back onto CAN2 with a Vector VN1610. Item by item I simplified this setup, but never saw any improvement.
The current setup has moved to a breadboard and involves 2x Teensy_4.0:
- Teensy #1 has one MCP2562-E/SN connected to CAN2. It transmits bursts of 14 random messages with periods of bus idle between bursts. Bus load is ~40%.
- Teensy #2 has three MCP2562-E/SN connected to CAN1-3. Messages from Teensy #1 are received FIFO on CAN2 and sequentially transmitted on CAN1. CAN1 is connected to CAN3 to provide ACK.
My hope is that you would be able to confirm this "lockup" behavior with 1x PJRC breakout and 1x skpang breakout.
Teensy #1 code:
Code:
#include <FlexCAN_T4.h>
#include <elapsedMillis.h>
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_32> VCAN;
CAN_message_t msgRand;
elapsedMicros usBurstIntervalTimer;
uint8_t burstCount = 14;
void setup() {
VCAN.begin();
VCAN.setClock(CLK_60MHz);
VCAN.setBaudRate(500000);
VCAN.setMaxMB(32);
for (int i; i < 32; i++) {
VCAN.setMB((FLEXCAN_MAILBOX)i, TX);
}
randomSeed(0);
usBurstIntervalTimer = 0;
delay(1000);
}
void loop() {
if ( usBurstIntervalTimer >= 6000 ) { // Burst interval timer expired
for (int i = 0; i < burstCount; i++) {
msgRand.id = random(0x100, 0x7FF);
msgRand.len = random(1, 8);
msgRand.buf[0] = random(0, 255);
VCAN.write(msgRand);
}
usBurstIntervalTimer = 0;
}
}
Teensy #2 code:
Code:
#include <FlexCAN_T4.h>
#include <elapsedMillis.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_64> LCAN;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> VCAN;
FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> LCAN3;
elapsedMillis msPrintTimer;
uint32_t rxCounterVCAN = 0;
uint32_t rxCounterLCAN3 = 0;
void setup() {
Serial.begin(500000);
// Setup VCAN (CAN2)
VCAN.begin();
VCAN.setClock(CLK_60MHz);
VCAN.setBaudRate(500000);
VCAN.enableFIFO();
VCAN.enableFIFOInterrupt();
VCAN.onReceive(canV2L);
// Setup LCAN (CAN1)
LCAN.begin();
LCAN.setClock(CLK_60MHz);
LCAN.setBaudRate(500000);
// Setup LCAN3 (CAN3) - needed to ACK TX msgs from LCAN (CAN1)
LCAN3.begin();
LCAN3.setClock(CLK_60MHz);
LCAN3.setBaudRate(500000);
LCAN3.enableFIFO();
LCAN3.enableFIFOInterrupt();
LCAN3.onReceive(rxIncLCAN3);
msPrintTimer = 0;
}
void loop() {
VCAN.events();
LCAN.events();
LCAN3.events();
if ( msPrintTimer > 1000 ) {
msPrintTimer = 0;
Serial.print("RX Count VCAN: "); Serial.print(rxCounterVCAN);
Serial.print(" LCAN3: "); Serial.println(rxCounterLCAN3);
}
}
void canV2L(const CAN_message_t &msg) {
CAN_message_t myMsg;
myMsg = msg;
myMsg.seq = 1;
LCAN.write(myMsg);
rxCounterVCAN++;
}
void rxIncLCAN3(const CAN_message_t &msg) {
rxCounterLCAN3++;
}
Typical serial output on from Teensy #2:
Code:
RX Count VCAN: 5 LCAN3: 4
RX Count VCAN: 2338 LCAN3: 2338
RX Count VCAN: 4662 LCAN3: 4662
RX Count VCAN: 6997 LCAN3: 6996
RX Count VCAN: 9324 LCAN3: 9324
RX Count VCAN: 11652 LCAN3: 11651
RX Count VCAN: 13986 LCAN3: 13986
RX Count VCAN: 16310 LCAN3: 16310
RX Count VCAN: 18646 LCAN3: 18644
RX Count VCAN: 20972 LCAN3: 20972
RX Count VCAN: 23298 LCAN3: 23297
RX Count VCAN: 25634 LCAN3: 25634
RX Count VCAN: 27958 LCAN3: 27958
RX Count VCAN: 30291 LCAN3: 30289
RX Count VCAN: 32620 LCAN3: 32620
RX Count VCAN: 34944 LCAN3: 34944
RX Count VCAN: 37282 LCAN3: 37281
RX Count VCAN: 39606 LCAN3: 37939
RX Count VCAN: 41936 LCAN3: 37939
RX Count VCAN: 44268 LCAN3: 37939
RX Count VCAN: 46592 LCAN3: 37939
RX Count VCAN: 48927 LCAN3: 37939
...
Thanks, Mike