🛠 Monter la Due sur un bus CAN 500 kbit/s avec un transceiver externe
Objectives
The SAM3X8E chip integrates TWO CAN controllers — the flagship feature of the Due for automotive and industrial applications — but the official datasheet is clear: “CAN: Yes (ext. transceiver needed)”. No transceiver is soldered onto the board. This tutorial sets up a 500 kbit/s CAN link using the due_can community library (collin80) and a small 3.3 V transceiver module, then sends and receives frames.
Hardware
- 1 Arduino Due
- 1 3.3 V CAN transceiver module (SN65HVD230, or TJA1050 powered at 3.3 V on the logic side)
- 2 120 Ω termination resistors (one at each end of the bus)
- 1 second CAN node for testing (another Due + transceiver, or a USB-CAN adapter like PCAN/Canable)
- Library: due_can (https://github.com/collin80/due_can), via the library manager
- Documented note: CAN0 pins are defined in the core (CANRX0=68, CANTX0=69); verify on your revision/clone that these signals are actually accessible before soldering anything
Complete Code
// Emetteur CAN0 a 500 kbit/s — transceiver externe obligatoire
#include <due_can.h>
void setup {
SerialUSB.begin(115200);
Can0.begin(CAN_500KBPS); // CAN0 @ 500 kbit/s
SerialUSB.println("CAN0 pret (500 kbit/s)");
}
void loop {
// 1) Emission periodique
can_frame tx;
tx.canId = 0x123;
tx.canIdLength = ONE_BIT;
tx.dataLength = 8;
uint32_t t = millis;
for (int i = 0; i < 8; i++) tx.data[i] = (t >> (i * 8)) & 0xFF;
Can0.sendMessage(tx); // non bloquant
// 2) Reception eventuelle
can_frame rx;
if (Can0.getMessage(rx)) {
SerialUSB.printf("Rx id=0x%X len=%u\n", rx.canId, rx.dataLength);
}
delay(10);
}
Expected Verification
With a second node (another Due or a USB-CAN adapter configured at 500 kbit/s), frames with ID 0x123, 8 bytes, containing millis in little-endian format, appear every 10 ms. On the USB-CAN adapter: candump displays 0123 [8] ... with an increasing counter. The two TX/RX LEDs on the transceiver blink.
Common Errors
- Looking for a CAN connector on the Due: there isn’t one — the official mention “ext. transceiver needed” means that without an external module, nothing appears on the cable, even if the code compiles.
- Using a 5 V transceiver (MCP2551 alone): the Due’s logic is 3.3 V; use a 3.3 V transceiver or one tolerant to 3.3 V on TXD.
- Forgetting the 120 Ω resistors at both ends of the bus: frames are sent, none arrive, or CRC errors appear.
- Mixing speeds: 250 kbit/s on one side, 500 kbit/s on the other = radio silence with no error message.
- Confusing the pins: CAN0 = RX 68 / TX 69 in the core (CAN1 = 88/89); on some clones, the signals are not routed to a connector — hence the prior verification on the board revision.
- Not declaring the due_can library: the SAM core does not provide a native CAN API; without the library,
Can0does not exist. - Wiring CAN_H/CAN_L backwards between two nodes: no ACK, no error message; swap the two wires.
Other tutorials for this board
- Faire clignoter la LED de l'Arduino Due et apprivoiser ses deux ports USB
- Lire un potentiomètre avec le vrai ADC 12 bits de la Due
- Allumer une LED externe en respectant les broches 3,3 V et 9 mA de la Due
- Générer une vraie tension analogique avec les DAC 12 bits (broches 66 et 67)
- Dialoguer avec un GPS (ou tout module TTL) sur Serial1 sans bloquer la boucle
- Scanner les deux bus I2C de la Due (Wire sur 20/21, Wire1 sur 70/71)
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinodac-onde.inoArduinoadc-12-bits.inoArduinopwm-12-bits.inoArduinogps-serial1.inoArduino