FlexRay is a cutting-edge communication protocol developed to meet the demanding requirements of advanced automotive systems. It offers high-speed and deterministic communication, making it ideal for applications that require real-time data transfer, such as drive-by-wire systems. Subsequent to the article on the physical layer of FlexRay protocol, in this article, we will delve into the data link layer of the FlexRay protocol.
FlexRay Bus Access
The FlexRay bus consists of a pair of communication channels, referred to as channel A and channel B, which operate in a dual-redundant mode. Each channel is a twisted pair cable employing differential signaling and NRZ encoding. These channels allow for fault tolerance, as if one channel fails, the system can seamlessly switch to the other. The channels are connected to the bus nodes, which can be electronic control units (ECUs) or sensors. The bus nodes communicate with each other by transmitting and receiving messages over the FlexRay bus.
To support both deterministic transmission and event-based communication, the FlexRay protocol employs two mechanisms - Time Division Multiple Access (TDMA) and Flexible Time Division Multiple Access (FTDMA).
The TDMA method defines a communication schedule or cycle which is split into time slots. Each node in the bus has one or more slots assigned in which it is granted access to the bus. This communication schedule is repeated periodically by all nodes in quick succession thereby providing a deterministic communication.
The FTDMA method is used to implement a dynamic segment which reserves a specific slot in the communication cycle that can be used by any node to transmit messages in a non-deterministic manner on a need basis.
FlexRay Communication Cycle
The FlexRay communication cycle is the core aspect of the protocol. It consists of a static segment, a dynamic segment, a symbol window, and a Network Idle Time (NIT). Of these, the static segment and NIT are always present and the other two are optional.
The static segment is deterministic and provides a fixed time slot for high-priority messages. The dynamic segment allows for flexible scheduling of lower priority messages. The symbol window defines the time period for transmitting and receiving data. During each communication cycle, the bus nodes exchange messages in a predefined sequence, ensuring timely and reliable communication.
FlexRay Clock and Timing Hierarchy
The FlexRay clock plays a crucial role in synchronizing the communication between bus nodes. It provides a reference for timing events and ensures that all nodes operate in a coordinated manner. The timing hierarchy in FlexRay consists of macroticks and microticks. A macrotick is divided into a fixed number of microticks, which allows for fine-grained timing control. The duration of a macrotick depends on the configuration of the FlexRay system, and the number of microticks determines the resolution of the protocol. It is established using a cluster-wide clock synchronization process. The microticks are more granular and are derived from the local oscillator at the node level. By carefully configuring the macroticks and microticks, the system can achieve the desired timing requirements. The timing hierarchy allows for precise and deterministic communication, ensuring that messages are transmitted and received at the correct time.
FlexRay Static Segment and Static Slot
The static segment in FlexRay provides a deterministic time slot for high-priority messages. It is divided into static slots, which are allocated to specific bus nodes based on their priority. A maximum of 1023 static slots can be defined on each channel per segment. The length of a static slot is determined by the longest FlexRay message, largest transmission delay (up to 2,5 µs) and the clock skew between nodes. Each static slot consists of four segments: Action Point Offset, FlexRay Frame, Channel Idle Delimiter (11 recessive bits) and Channel Idle.
During the static segment, each bus node is guaranteed a fixed amount of time to transmit its message. Having no collision or delay, this deterministic allocation ensures that high-priority messages are transmitted without delay, enabling real-time communication in critical applications.
FlexRay Dynamic Segment and Dynamic Slot
Unlike the static segment, the dynamic segment in FlexRay allows for flexible scheduling of lower priority messages. It provides a time window during which bus nodes can transmit their messages based on a predefined priority scheme. The dynamic slot is allocated dynamically to bus nodes based on their priority, allowing for efficient utilization of the available bandwidth. Quite similar to static slots, the dynamic slots have an additional field – Dynamic Trailing Sequence (DTS) to align to minislot timings. Each slot is provided with a unique identifier and carry payload of different sizes. If any event occurs in a node and it matched with the corresponding slots identifier of that not, then it can start sending data. If it is a longer message, then the next node time slot is moved backward. This flexibility ensures that lower priority messages can be transmitted without affecting the timing constraints of high-priority messages.
FlexRay Symbol Window
The symbol window is a segment within the FlexRay communication cycle dedicated to network maintenance and signaling. It facilitates synchronization of clocks across all nodes in the network and enables essential network functions. Special bit patterns called symbols are transmitted. Some of the FlexRay Symbols are:
- Collision avoidance symbol: used by cold start nodes to start communication
- Media test symbol: Used to test the bus guardian
- Wake-up symbol: Used to initiate the wake-up process
An optional bus guardian in the FlexRay network provides an enable signal to the nodes that allows it ti transmit. If it notices a node transmitting a message at the wrong time, it can remove the enable signal to guarantee bandwidth to more important nodes.
FlexRay Network Idle Time
The FlexRay network idle time is a fixed duration within the FlexRay communication cycle that ensures clock synchronization between nodes. This quiet period allows for the maintenance of clock accuracy and synchronization, preventing drift or desynchronization between nodes. The FlexRay network idle time is crucial for the overall stability and reliability of the FlexRay network.
FlexRay Frame Format
The FlexRay frame format defines the organization of the data transmitted over the bus. It consists of three parts: the header, the payload, and the trailer.
The header contains information about the frame, such as its length and priority and consists of the following parts
Indicator bits: Specifies the message type and cloud be one of
- Startup frame indicator – sent in the static segment as a startup frame
- Sync frame indicator – sent in the static segment for synchronization
- Null frame indicator – specifies if payload is valid or not
- Payload Preamble Indicator – specifies if a network management vector is sent in the payload
Payload length : in words up to 127 → up to 254 bytes CRC : Computed over the ID, payload length and some indicator bits Cycle count : the current communication cycle count (counts up to 63)
The payload carries the actual data being transmitted and as described earlier all messages in the static segment have the same payload size. The trailer contains error detection and correction information to ensure the integrity of the transmitted data covering both header and payload.
FlexRay Frame Encoding
FlexRay frame format uses a specific encoding scheme to transmit data over the bus. Each frame consists of the following components.
- Transmit Start Sequence - TSS : 5-15 low bits
- Frame Start Sequence - FSS : 1 high bit
- Byte Start Sequence - BSS : 1 high bit followed by 1 low bit
- Frame End Sequence - FES : 1 low bit followed by 1 high bit
Each bit is transmitted as a high for 8 clock cycles. The receiver determines the bit by taking the majority of the last 5 samples.
FlexRay also employs complex frame synchronization mechanisms to ensure all nodes are in sync and communication cycles are started at the same time.
Conclusion
FlexRay is a highly robust and reliable protocol that can easily meet the needs of a rugged environment. Hence the reason for a wide adoption in automotive communication systems by providing a high-speed and deterministic protocol for real-time applications. With its advanced features, such as fault tolerance, scalability, and efficient bandwidth utilization, FlexRay has become a key technology in the automotive industry. Embien has worked in leading semiconductor offerings and helped customers realize many FlexRay network and achieve a high FlexRay communication throughput. With deep understanding of the FlexRay frame format and underlying environment, our engineers can help realize your FlexRay designs quicker.