EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #454 background imageLoading...
Page #454 background image
Chapter 2. API Reference
1. TWAI Protocol Summary
2. Signals Lines and Transceiver
3. Driver Configuration
4. Driver Operation
5. Examples
TWAI Protocol Summary
The TWAI is a multi-master, multi-cast, asynchronous, serial communication protocol. TWAI also supports error
detection and signalling, and inbuilt message prioritization.
Multi-master: Any node on the bus can initiate the transfer of a message.
Multi-cast: When a node transmits a message, all nodes on the bus will receive the message (i.e., broadcast) thus
ensuring data consistency across all nodes. However, some nodes can selectively choose which messages to accept
via the use of acceptance filtering (multi-cast).
Asynchronous: The bus does not contain a clock signal. All nodes on the bus operate at the same bit rate and
synchronize using the edges of the bits transmitted on the bus.
Error Detection and Signalling: Every node will constantly monitor the bus. When any node detects an error, it
will signal the detection by transmitting an error frame. Other nodes will receive the error frame and transmit their
own error frames in response. This will result in an error detection being propagated to all nodes on the bus.
Message Priorities: Messages contain an ID eld. If two or more nodes attempt to transmit simultaneously, the
node transmitting the message with the lower ID value will win arbitration of the bus. All other nodes will become
receivers ensuring that there is at most one transmitter at any time.
TWAI Messages TWAI Messages are split into Data Frames and Remote Frames. Data Frames are used to deliver
a data payload to other nodes, whereas a Remote Frame is used to request a Data Frame from other nodes (other nodes
can optionally respond with a Data Frame). Data and Remote Frames have two frame formats known as Extended
Frame and Standard Frame which contain a 29-bit ID and an 11-bit ID respectively. A TWAI message consists of
the following fields:
29-bit or 11-bit ID: Determines the priority of the message (lower value has higher priority).
Data Length Code (DLC) between 0 to 8: Indicates the size (in bytes) of the data payload for a Data Frame,
or the amount of data to request for a Remote Frame.
Up to 8 bytes of data for a Data Frame (should match DLC).
Error States and Counters The TWAI protocol implements a feature known as fault confinementwhere a
persistently erroneous node will eventually eliminate itself form the bus. This is implemented by requiring every
node to maintain two internal error counters known as the Transmit Error Counter (TEC) and the Receive Error
Counter (REC). The two error counters are incremented and decremented according to a set of rules (where the
counters increase on an error, and decrease on a successful message transmission/reception). The values of the
counters are used to determine a nodes error state, namely Error Active, Error Passive, and Bus-Off.
Error Active: A node is Error Active when both TEC and REC are less than 128 and indicates that the node is
operating normally. Error Active nodes are allowed to participate in bus communications, and will actively signal the
detection of any errors by automatically transmitting an Active Error Flag over the bus.
Error Passive: A node is Error Passive when either the TEC or REC becomes greater than or equal to 128.
Error Passive nodes are still able to take part in bus communications, but will instead transmit a Passive Error Flag
upon detection of an error.
Bus-Off: A node becomes Bus-Off when the TEC becomes greater than or equal to 256. A Bus-Off node is
unable influence the bus in any manner (essentially disconnected from the bus) thus eliminating itself from the bus.
A node will remain in the Bus-Off state until it undergoes bus-off recovery.
Espressif Systems 443
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish