You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just Teensy 4.1 to send and receive CAN messages in same channel (CAN1) (same as example code (CAN2.0_example_FIFO_with_interrupts.ino)).
Transmit is working fine but reception via interrupt is not happening. Even tried to read CAN frames via read function but still not works.
Below is the code (code is same as example code (CAN2.0_example_FIFO_with_interrupts.ino)). Additonally added mailbox status at the end of loop,
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0;
Try moving the Can0.mailboxStatus(); from loop() to inside the "if" block. Since that function prints a bunch to serial, you definitely don't want to call it every single loop().
If mailbox status still shows all those mailboxes as transmitting, something outside the teensy is likely the culprit. Do you have another device on the bus that is ACK'ing the messages the teensy is transmitting?
Hi,
I was just Teensy 4.1 to send and receive CAN messages in same channel (CAN1) (same as example code (CAN2.0_example_FIFO_with_interrupts.ino)).
Transmit is working fine but reception via interrupt is not happening. Even tried to read CAN frames via read function but still not works.
Below is the code (code is same as example code (CAN2.0_example_FIFO_with_interrupts.ino)). Additonally added mailbox status at the end of loop,
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0;
void setup(void) {
Serial.begin(115200); delay(400);
//pinMode(6, OUTPUT); digitalWrite(6, LOW); /* optional tranceiver enable pin */
Can0.begin();
Can0.setBaudRate(1000000);
Can0.setMaxMB(16);
Can0.enableFIFO();
Can0.enableFIFOInterrupt();
Can0.onReceive(canSniff);
Can0.mailboxStatus();
}
void canSniff(const CAN_message_t &msg) {
Serial.print("MB "); Serial.print(msg.mb);
Serial.print(" OVERRUN: "); Serial.print(msg.flags.overrun);
Serial.print(" LEN: "); Serial.print(msg.len);
Serial.print(" EXT: "); Serial.print(msg.flags.extended);
Serial.print(" TS: "); Serial.print(msg.timestamp);
Serial.print(" ID: "); Serial.print(msg.id, HEX);
Serial.print(" Buffer: ");
for ( uint8_t i = 0; i < msg.len; i++ ) {
Serial.print(msg.buf[i], HEX); Serial.print(" ");
} Serial.println();
}
void loop() {
Can0.events();
static uint32_t timeout = millis();
if ( millis() - timeout > 200 ) {
CAN_message_t msg;
msg.id = random(0x1,0x7FE);
for ( uint8_t i = 0; i < 8; i++ ) msg.buf[i] = i + 1;
Can0.write(msg);
}
Can0.mailboxStatus();
}
Mailbox status is below,
16:09:08.144 -> FIFO Enabled --> Interrupt Enabled
16:09:08.144 -> FIFO Filters in use: 8
16:09:08.144 -> Remaining Mailboxes: 8
16:09:08.144 -> MB8 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x76D)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB9 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x4BC)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB10 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x489)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB11 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x599)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB12 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x151)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB13 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x5F2)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB14 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0x641)(Payload: 1 2 3 4 5 6 7 8)
16:09:08.144 -> MB15 code: TX_DATA (Transmitting)(Standard Frame)(ID: 0xC6)(Payload: 1 2 3 4 5 6 7 8)
Hardware connection looks fine.
I don't know what's wrong here.
The text was updated successfully, but these errors were encountered: