meta data for this page
  •  

This is an old revision of the document!


lamaPLC: TWAI basics

The TWAI protocol was developed/applied by Espressif for the ESP32 microcontroller family, effectively implementing CAN Classic.

TWAI is a highly reliable, multi-master, real-time, serial asynchronous communication protocol designed for automotive and industrial applications.

The TWAI controller is not compatible with ISO11898-1 FD Format frames and will interpret them as errors. TWAI is effectively “CAN Classic,” not CAN-FD, which is what the automotive industry & promoters such as STMicroelectronics, Infineon, NXP, Texas Instruments, Kvaser, Bosch, Daimler, and GM wouldn't appreciate Espressif referring to their transceiver as “CAN,” which could confuse.

The TWAI standard supports both 11-bit and 29-bit identifiers. The protocol supports message prioritization with lossless arbitration, automatic retransmission, and fault confinement mechanisms. The ESP32 microcontroller includes TWAI controllers, allowing for the creation of one driver instance, as follows:

PlatformTWAI busses
ESP82660
ESP321
ESP32-S21
ESP32-S31
ESP32-C2(ESP8684)0
ESP32-C3(ESP8685)1
ESP32-C52
ESP32-C62
ESP32-C612
ESP32-H21
ESP32-P43

TWAI port specifically

  • TX/RX: For a single-node, you can directly short the TX and RX pins to omit the transceiver.
  • BUS_OFF: (optional): Outputs a low logic level (0 V) when the TWAI controller enters the bus-off state. Otherwise, it remains at a high logic level (3.3 V).
  • CLK_OUT: (optional) Outputs the controller's time quantum clock, which is a divided version of the source clock.

TWAI topics on lamaPLC