Francisco Tavares
Member
Hi everyone,
I’m having trouble getting two Teensy 4.0 boards to talk to each other over CAN using SN65HVD232D transceivers. Internal loopback passes on both boards, but nothing is received over the physical bus.
Hardware Setup
Wiring (SN65HVD232D)
Code
Sender
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
CAN_message_t msg;
void setup() {
Serial.begin(115200);
delay(1000);
can2.begin();
can2.setBaudRate(125000);
Serial.println("Sender ready");
}
void loop() {
msg.id = 0x123;
msg.len = 1;
msg.buf[0] = 42;
if (can2.write(msg)) {
Serial.println("Sent!");
} else {
Serial.println("Failed!");
}
delay(1000);
}
Receiver
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
CAN_message_t msg;
void setup() {
Serial.begin(115200);
delay(1000);
can2.begin();
can2.setBaudRate(125000);
Serial.println("Receiver ready");
}
void loop() {
if (can2.read(msg)) {
Serial.print("Received: ");
Serial.println(msg.buf[0]);
}
delay(10);
}
I’m having trouble getting two Teensy 4.0 boards to talk to each other over CAN using SN65HVD232D transceivers. Internal loopback passes on both boards, but nothing is received over the physical bus.
Hardware Setup
| Item | Details |
|---|---|
| Microcontrollers | 2 × Teensy 4.0 |
| Transceivers | 2 × SN65HVD232D |
| Termination | 120 Ω at each end |
| CAN pins tested | CAN1 (22/23) and CAN2 (0/1) |
Wiring (SN65HVD232D)
| Transceiver Pin | Connection |
|---|---|
| 1 (D) | Teensy CAN_TX |
| 2 (GND) | Ground |
| 3 (VCC) | 3.3 V |
| 4 (R) | Teensy CAN_RX |
| 6 (CANL) | Other transceiver CANL + 120 Ω |
| 7 (CANH) | Other transceiver CANH + 120 Ω |
| 8 and 5 (NC) | Nothing |
Code
Sender
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
CAN_message_t msg;
void setup() {
Serial.begin(115200);
delay(1000);
can2.begin();
can2.setBaudRate(125000);
Serial.println("Sender ready");
}
void loop() {
msg.id = 0x123;
msg.len = 1;
msg.buf[0] = 42;
if (can2.write(msg)) {
Serial.println("Sent!");
} else {
Serial.println("Failed!");
}
delay(1000);
}
Receiver
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
CAN_message_t msg;
void setup() {
Serial.begin(115200);
delay(1000);
can2.begin();
can2.setBaudRate(125000);
Serial.println("Receiver ready");
}
void loop() {
if (can2.read(msg)) {
Serial.print("Received: ");
Serial.println(msg.buf[0]);
}
delay(10);
}
What Works
- Internal loopback succeeds on both CAN controllers and baud rates.
- Code builds and runs without errors.
What Doesn’t Work
- No external CAN traffic detected.
- Receiver never prints any messages.
- Sender alternates between “Sent!” and “Failed!” after a few seconds.
Observations & Troubleshooting So Far
- Sender says “Sent!” even when transceivers are unplugged.
→ Seems can2.write() only confirms that a frame was queued internally, not that it was acknowledged on the bus. - Tried baud rates 125 k, 250 k, 500 k — no change.
- Tested both CAN1 and CAN2, with and without FIFO/mailbox configs.
- Double-checked wiring, 3.3 V supply, and both 120 Ω terminators.
Questions
- Is there a quirk with the SN65HVD232D I’m missing?
- Should can.write() return false if the frame isn’t acknowledged?
- Any known FlexCAN_T4 + SN65HVD232D issues?
- Would switching to something like an MCP2551 be more reliable?