When I was testing the CAN communication, I found that the other party did not return any data. Since I couldn’t verify the CAN function of the motor, I adopted the loopback method to verify the CAN function of my Teensy 4.1. When I used the hardware loopback method of the Teensy 4.1 to display that it could receive and send CAN data, but when I connected a CAN transceiver to test the software loopback method, it failed to be realized. How should I verify it? Can anyone help me? Thank you very much!
-
Internal loopback ≠ real CAN bus. It only proves the FlexCAN peripheral is alive.
-
External loopback with one node will fail because no ACK is generated.
-
Minimum valid test: Two nodes on the bus (Teensy+Teensy, or Teensy+USB-CAN adapter) with 120 Ω termination, shared GND, same bitrate, and transceiver enabled.
-
If testing the motor, use a scope to verify the ACK bit is being asserted; if not, the motor is not hearing you.
Do you have a 2nd unit to test with by chance? There are a lot of things that can go awry with CANbus, here’s some hardware stuff to check:
| Item | Requirement | Common Mistake |
|---|---|---|
| Termination | 120 Ω between CANH and CANL at each physical end of the bus. If you have only two nodes (Teensy + motor), put 120 Ω at the Teensy side and 120 Ω at the motor side. The resistance measured between CANH and CANL with power off should be roughly 60 Ω (two 120 Ω resistors in parallel) . | Missing resistor or only one node terminated. |
| Transceiver mode pin | On SN65HVD230/231, pin 8 (RS) must be tied LOW (to GND) for high-speed/normal mode. If it is floating or pulled high, the transceiver is in standby/slope-control mode and will not transmit . | Forgetting to drive the RS or EN pin on the breakout board. |
| Ground | All devices must share a common GND reference. CAN is differential, but the transceiver’s common-mode range requires a shared ground . | Powering Teensy and motor from separate supplies with no GND connection. |
| Bitrate | Every node on the bus must use the exact same bitrate (e.g., 250 kbps, 500 kbps, 1 Mbps). | Teensy at 250k, motor at 500k, or PCAN adapter at 1M. |
| Pins | Teensy 4.1 CAN1 = pins 22 (CTX1) & 23 (CRX1); CAN2 = pins 0 (CTX2) & 1 (CRX2); CAN3 = pins 30 (CTX3) & 31 (CRX3). Make sure your code matches the physical wiring . | Using CAN1 in code but wired to pins 30/31. |
Or, if don’t have a 2nd unit/node you can try Single-Board Verification (no motor needed) using both CAN controllers on the same Teensy 4.1 with two transceivers wired back-to-back:
Teensy CAN1 (pins 22/23) → Transceiver A → CANH/CANL ─┐
├─ 120 Ω terminator
Teensy CAN2 (pins 0/1) → Transceiver B → CANH/CANL ─┘
This gives you a real bus with two real nodes, so ACKs are generated properly. If you only have one transceiver, you cannot do a valid external loopback test because no ACK will arrive.
Thank you very much! Now I am attempting to verify by connecting two transceivers back-to-back on the same Teensy 4.1 and using two CAN controllers to operate. If I cannot achieve the desired effect, I will try using two single-board computers for verification.