21 Two-wire Automotive Interface (TWAI)
The current error state of the TWAI controller is indicated via a combination of the following values and status
bits: TEC, REC, TWAI_ERR_ST, and TWAI_BUS_OFF_ST. Certain changes to these values and bits will also trigger
interrupts, thus allowing the users to be notified of error state transitions (see section 21.5.3). The following
figure
21-10
shows the relation between the error states, values and bits, and error state related interrupts.
21.5.7.1 Error Warning Limit
The Error Warning Limit (EWL) feature is a configurable threshold value for the TEC and REC, where if ex-
ceeded, will trigger an interrupt. The EWL is intended to serve as a warning about severe TWAI bus er-
rors, and is triggered before the TWAI controller enters the Error Passive state. The EWL is configured in the
TWAI_ERR_WARNING_LIMIT_REG
TWAI_ERR_WARNING_LIMIT_REG
or equal to the EWL value, the
TEC and REC are smaller than the EWL value, the
Interrupt is triggered whenever the value of the
21.5.7.2 Error Passive
The TWAI controller is in the Error Passive state when the TEC or REC value exceeds 127. Likewise, when both
the TEC and REC are less than or equal to 127, the TWAI controller enters the Error Active state. The Error Passive
Interrupt is triggered whenever the TWAI controller transitions from the Error Active state to the Error Passive
state or vice versa.
21.5.7.3 Bus-Off and Bus-Off Recovery
The TWAI controller enters the Bus-Off state when the TEC value exceeds 255. On entering the Bus-Off state,
the TWAI controller will automatically do the following:
• Set REC to 0
• Set TEC to 127
• Set the
TWAI_BUS_OFF_ST
• Enter Reset Mode
Espressif Systems
Figure 21-10. Error State Transition
and can only be configured whilst the TWAI controller is in Reset Mode. The
has a default value of 96. When the values of TEC and/or REC are larger than
TWAI_ERR_ST
bit is immediately set to 1. Likewise, when the values of both the
TWAI_ERR_ST
TWAI_ERR_ST
bit to 1
566
Submit Documentation Feedback
bit is immediately reset to 0. The Error Warning
bit (or the TWAI_BUS_OFF_ST) changes.
ESP32 TRM (Version 5.2)
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?