I’m trying to get my Teensy 4.1 to communicate over CAN but running into issues with the CAN_TX signal.
Any ideas on what might be causing this issue?
Setup:
- Teensy 4.1 connected to a breadboard
- Dupont wires connecting to an SN65HVD230 CAN transceiver breakout board
- Tested with and without a 120Ω termination resistor
Issue:
I’m using an example sketch to test. Before sending a message, CAN_TX sits at a steady 3.3V. However, after the first transmission attempt, CAN_TX starts oscillating between 0V and 3.3V (as shown in the video). I’ve also probed CANH and CANL but still can’t get proper communication.Any ideas on what might be causing this issue?
Video:
Code:
Code:
#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 > 5000 ) {
Serial.printf("Sending Message\n");
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);
timeout = millis();
}
}