Functional Description

Protocol Frame Formats

According to the ISO 11898-1 standard, CAN supports four frame types: Data Frame, Remote Frame, Error Frame, and Overload Frame. Additionally, the Inter-Frame Space separates consecutive frames.

Data Frame

Data frames carry data payloads between nodes and are the most common frame type. CAN supports standard data frames (11-bit identifier) and extended data frames (29-bit identifier).

  • Standard Data Frame: Uses an 11-bit identifier (Base ID), with a maximum payload of 8 bytes.

    ../../../_images/standard_data_frame.svg

    Standard Data Frame

  • Extended Data Frame: Uses a 29-bit identifier (Extended ID), distinguished from standard frames by the IDE bit.

    ../../../_images/extended_data_frame.svg

    Extended Data Frame

A data frame consists of the following functional segments in sequential order:

  • Start of Frame (SOF): A single dominant bit marking the beginning of the frame, used for hard synchronization.

  • Arbitration Field: Contains the identifier (ID), RTR, IDE, and SRR bits. The ID determines the message priority; a lower numerical value indicates a higher priority.

  • Control Field: Contains the Data Length Code (DLC, 4 bits) and reserved bits. The DLC specifies the number of bytes in the data field (0 to 8).

  • Data Field: The payload, ranging from 0 to 8 bytes, transmitted MSB first.

  • CRC Field: Contains a 15-bit CRC sequence and a 1-bit recessive CRC delimiter, computed automatically by hardware.

  • ACK Field: The transmitter outputs a recessive bit; any node that has successfully received the frame responds with a dominant bit.

  • End of Frame (EOF): 7 consecutive recessive bits marking the end of the frame.

Remote Frame

Remote frames are used to request a specific node to transmit data. Their structure is similar to that of a data frame, but the RTR bit is recessive and there is no data field. Remote frames support both standard and extended formats.

../../../_images/standard_remote_frame.svg

Standard Remote Frame

../../../_images/extended_remote_frame.svg

Extended Remote Frame

Error Frame

An error frame is transmitted when a node detects a bus error to disrupt the current communication and notify other nodes. It consists of an error flag (6 bits) and an error delimiter (8 recessive bits). There are two types:

  • Active Error Flag: Transmitted by an error-active node, consisting of 6 consecutive dominant bits.

  • Passive Error Flag: Transmitted by an error-passive node, consisting of 6 consecutive recessive bits.

../../../_images/active_error_frame.svg

Active Error Frame

../../../_images/passive_error_frame.svg

Passive Error Frame

Overload Frame

An overload frame is used to request additional inter-frame delay. Its structure is similar to an active error frame, consisting of an overload flag (6 consecutive dominant bits) and an overload delimiter (8 recessive bits).

../../../_images/overload_frame.svg

Overload Frame

Inter-Frame Space

The ISO 11898-1 standard defines the Inter-Frame Space, which separates a data frame or remote frame from any preceding frame. The Inter-Frame Space consists of the following phases:

  • Intermission: 3 consecutive recessive bits. During this period, no node is permitted to initiate a transmission.

  • Suspend: An error-passive node must wait an additional 8 recessive bit times after the intermission before participating in the next bus arbitration. Error-active nodes are not subject to this restriction.

  • Bus Idle: If no data transmission occurs after the intermission and suspend times have elapsed, the bus enters the idle state, at which point any node may initiate the next transmission.

../../../_images/can_intermission.svg

Inter-Frame Space

Note

No inter-frame space is inserted before an error frame or an overload frame.

Clock Domains

Each CAN module has two clock domains: core_clk for primary CAN functions, and a low-frequency clock (OSC4M) for the wakeup circuit. The core_clk clock domain structure is shown below:

../../../_images/core_clk_clock_domain.svg

Clock Source Selection

core_clk provides three selectable clock sources:

  • XTAL 40 MHz

  • USB PLL

  • SYS PLL

The clock source is selected via the cksl_can field in REG_LSYS_CKSL_GRP0: cksl_can = 0 selects XTAL (40 MHz), cksl_can = 1 selects USB PLL (default), and cksl_can = 3 selects SYS PLL.

  • If XTAL is selected (cksl_can = 0), the 40 MHz crystal oscillator clock is used directly as core_clk.

  • If a PLL is selected (USB PLL or SYS PLL), two additional parameters must be configured:

    • Clock enable (e.g., fen_usb_pll_can in REG_LSYS_CKD_FEN_USB_PLL)

    • Clock divider (e.g., ckd_usb_pll_can in REG_LSYS_CKD_USB_PLL_GRP0).

Bit Timing and Baud Rate

The chip provides two CAN modules. Bit timing parameters can be configured individually for each CAN node, supporting communication rates of up to 1 Mbit/s.

Bit Timing Decomposition

According to ISO 11898-1, a bit time is divided into four segments: Synchronization Segment (Sync_Seg), Propagation Segment (Prop_Seg), Phase Buffer Segment 1 (Phase_Seg1), and Phase Buffer Segment 2 (Phase_Seg2):

  • Sync_Seg: Fixed at 1 Tq. This is the expected position for bit level transitions, used to synchronize all nodes on the bus.

  • Prop_Seg: Compensates for signal propagation delay on the physical bus and internal hardware delay of the transceiver.

  • Phase_Seg1: A buffer segment before the sample point, which can be temporarily lengthened during resynchronization.

  • Phase_Seg2: A buffer segment after the sample point, which can be temporarily shortened during resynchronization.

A Time Quantum (Tq) is the minimum time unit in bit timing configuration. The length of all time segments is specified in units of Tq. The Tq duration is derived from core_clk divided by the Baud Rate Prescaler (BRP):

Tq = (can_brp + 1) / core_clk

The following figure shows the timing diagram of a complete bit time:

../../../_images/bit_timing.svg

The controller samples the bus level at the boundary between Phase_Seg1 and Phase_Seg2 (the sample point). By adjusting the length of each segment, the sample point position within the bit time can be controlled. A complete bit time typically consists of 8 to 25 Tq. The Tq allocation rules for each segment are as follows:

Bit Time Segment Parameter Ranges

Parameter

Range

Description

Prescaler (BRP)

1 ~ 32

Tq = (can_brp + 1) / core_clk

Sync_Seg

1 Tq (Fixed)

Synchronizes all nodes on the bus

Prop_Seg

1 ~ 8 Tq

Compensates for physical delay times within the network

Phase_Seg1

1 ~ 8 Tq

Compensates for edge phase errors; can be lengthened during resync

Phase_Seg2

2 ~ 8 Tq

Compensates for edge phase errors; can be shortened during resync

SJW (Sync Jump Width)

1 ~ 4 Tq

May not exceed the lesser of Phase_Seg1 and Phase_Seg2

Bit Timing Register Configuration

Bit timing parameters are programmed via the CAN_BIT_TIMING register. To simplify configuration, the controller merges Prop_Seg and Phase_Seg1 into can_tseg1, while Phase_Seg2 corresponds to can_tseg2. Note that can_brp, can_tseg1, and can_tseg2 are 0-based register fields — the hardware internally adds 1 to obtain the actual divider or segment length. The register field mapping is as follows:

  • can_brp: Prescaler. Actual divider = can_brp + 1; Tq = (can_brp + 1) / core_clk.

  • can_tseg1: Merged segment (Prop_Seg + Phase_Seg1). Actual length = can_tseg1 + 1; register value = Prop_Seg + Phase_Seg1 - 1.

  • can_tseg2: Phase_Seg2. Actual length = can_tseg2 + 1; register value = Phase_Seg2 - 1.

  • can_sjw: Sync Jump Width. can_sjw = SJW (direct mapping, no offset).

The baud rate calculation formula is:

Baud Rate = core_clk / ((can_brp + 1) × (1 + (can_tseg1 + 1) + (can_tseg2 + 1)))

For example, with core_clk = 40 MHz, can_brp = 1, can_tseg1 = 14, and can_tseg2 = 3, the baud rate is 1 Mbit/s:

Baud Rate = 40 / ((1 + 1) × (1 + (14 + 1) + (3 + 1)))
          = 40 / (2 × 20)
          = 1 Mbit/s

The sample point position within the bit time can be calculated using the following formula:

Sample Point = (1 + can_tseg1 + 1) / (1 + (can_tseg1 + 1) + (can_tseg2 + 1))

In this configuration, the sample point is located at 80% of the bit time.

The following table lists reference configurations for commonly used baud rates with core_clk = 40 MHz:

Common Baud Rate Configuration Reference (core_clk = 40 MHz)

Baud Rate

can_brp

can_tseg1

can_tseg2

SJW

Sample Point

1 Mbit/s

1

14

3

1

80%

500 kbit/s

3

14

3

1

80%

250 kbit/s

7

14

3

1

80%

125 kbit/s

15

14

3

1

80%

Triple Sampling Mode

Setting can_tri_sample in CAN_CTL to 1 enables triple sampling mode. In this mode, the controller samples the input signal three times near the sample point, with each sample separated by 1 Tq. The final logic level is determined by a majority vote of the three sampled values. This effectively filters out signal glitches and improves communication robustness.

../../../_images/triple_sample_mode.svg

Note

Triple sampling mode is recommended for low bit rates (below 125 kbit/s). At lower rates, each Tq has a longer duration, making the signal more susceptible to external interference. The triple sampling mechanism provides better filtering under such conditions.

Operating Modes

The CAN module supports three operating modes: Normal Mode, Sleep Mode, and Test Mode.

Normal Mode

This is the default operating mode. All submodules (Message Processor, RAM, Protocol Core, and Registers) operate collaboratively to perform message transmission and reception, error handling, and interrupt reporting.

Sleep Mode

In Sleep Mode, most submodules are clock-gated; only the wakeup circuit remains active. The CAN cannot transmit or receive any frames, and both the module and the system enter a low-power state.

Sleep mode is entered by setting can_sleep_en in CAN_SLEEP_MODE to 1. The CAN uses the low-frequency OSC4M clock to drive the wakeup circuit. The system must keep OSC4M active to support wakeup monitoring.

The wakeup circuit operates only in Sleep Mode. It monitors the duration of the dominant level (low level) on the Rx pin and compares it against a predefined threshold:

../../../_images/block_of_wakeup_circuit.svg
  • If the low-level duration exceeds the threshold, a wakeup signal is generated to reactivate the CAN module and the entire system.

  • If the threshold is not exceeded, the module and the system remain in the sleep state.

Warning

  • Wakeup detection is independent of the protocol frame content. The frame that triggers the wakeup cannot be received by the CAN. Whether subsequent data can be received depends on the sender’s retransmission mechanism.

  • Before wakeup, ensure that the external transceiver is in its normal operating state rather than standby or sleep mode.

Test Mode

CAN provides two test modes: Silent Mode and Loopback Mode, primarily for node self-testing and bus debugging. To enter test mode, set test_mode_en in CAN_CTL to 1 to enable test functions, then select the specific test mode via can_test_cfg in CAN_TEST.

  1. Silent Mode: Also referred to as Bus Monitoring Mode in the ISO 11898-1 standard. In this mode, the CAN receives all frames on the bus normally but does not transmit any frames (including data and error frames) or ACK bits, and therefore does not affect the bus. This mode is commonly used for analyzing bus communication traffic.

    ../../../_images/silence_mode.svg
  2. Loopback Mode: Used to verify the internal digital logic of the CAN controller. It is divided into External Loopback and Internal Loopback:

    • External Loopback: The frame is physically transmitted from the Tx pin onto the bus and can be captured by an external analyzer. The controller receives only frames from its own Tx end, ignoring all other frames on the bus.

    • Internal Loopback: The frame is looped back entirely within the CAN controller and is not output from the Tx pin to the external bus.

    ../../../_images/external_loopback_left_and_internal_loopback_left.svg

    External Loopback Mode

    ../../../_images/external_loopback_left_and_internal_loopback_right.svg

    Internal Loopback Mode

Message Processing and Buffer Management

The Message Processor reduces CPU load by taking over storage scheduling for message transmission and reception. It arbitrates RAM access between the CPU (APB bus) and the Protocol Core to ensure data consistency.

  • Transmit direction: Schedules pending messages for transmission based on priority.

  • Receive direction: Scans RAM and applies filtering and masking mechanisms to allocate storage space for received messages.

The architectural relationship between RAM, Message Processor, Protocol Core, and Registers is shown below:

../../../_images/relationship_between_ram_message_processor_can_core_and_registers.svg

CAN uses registers such as CAN_RAM_ARB, CAN_RAM_MASK, CAN_RAM_CS, CAN_RAM_DATA, and CAN_MB_BA_END to manage message buffers.

Message Buffer Configuration

Each CAN module is equipped with an independent RAM (352 × 32 bits), logically divided into 16 message buffers (MB0 ~ MB15). Each buffer can store only one CAN message, with individually configurable space (default: 6 × 32 bits).

The base address of each buffer is set via can_msgx_ba in CAN_MBx_CTRL (word-aligned), and the valid RAM address range is defined by can_msg_ba_end in CAN_MB_BA_END.

For example, if can_msg0_ba in CAN_MB0_CTRL is 0x0 and can_msg1_ba in CAN_MB1_CTRL is 0x6, MB0 is allocated 6 × 32 bits of storage space.

Receive Filters

The Rx processor uses three types of receive filters for hardware-level message filtering. These filters can be flexibly combined to meet various application requirements.

  • Identifier (ID) Filter: can_ram_id (29 bits) in CAN_RAM_ARB defines the expected message ID, and can_ram_id_mask (29 bits) in CAN_RAM_MASK provides the corresponding mask:

    • A mask bit of 0 means the corresponding bit is not compared (i.e., don’t care; always matches).

    • A mask bit of 1 means the corresponding bit in the received frame must strictly match can_ram_id.

    Note

    The filtering logic depends on the frame type:

    • Standard frames (11-bit Base ID): only bits [28:18] of can_ram_id are compared.

    • Extended frames (29-bit Extended ID): the full range of can_ram_id bits [28:0] is compared.

    For example, when receiving standard frames, if bits [28:18] of CAN_RAM_ARB are set to 0x1 and bits [28:18] of CAN_RAM_MASK are set to 0x7FC (the lowest two mask bits are 0), frames with Base IDs 0x00 through 0x03 will all be received.

  • Identifier Extension (IDE) Filter: can_ram_ide in CAN_RAM_ARB and can_ram_ide_mask in CAN_RAM_MASK control frame format filtering:

    • can_ram_ide_mask = 0: Frame format is not distinguished; both standard and extended frames are received.

    • can_ram_ide_mask = 1: Only frames whose IDE bit matches can_ram_ide are received.

    • can_ram_ide = 0 and can_ram_ide_mask = 1: Only standard frames are received.

    • can_ram_ide = 1 and can_ram_ide_mask = 1: Only extended frames are received.

  • Remote Transmission Request (RTR) Filter: can_ram_rtr_mask in CAN_RAM_MASK controls frame type filtering:

    • can_ram_rtr_mask = 0: Frame type is not distinguished; both data and remote frames are received.

    • can_ram_rtr_mask = 1: Only frames whose RTR bit matches can_ram_rtr in CAN_RAM_ARB are received.

Message Transmission and Reception Flow

  1. Transmission Flow: The Message Processor continuously scans all buffers in RAM to determine if there are messages pending for transmission, and decides the transmission order based on priority. When the bus is in an intermission, idle, or safe state, the selected message is transferred to the Protocol Core for physical transmission. The CPU configuration steps are as follows:

    1. Fill in the transmission parameters in the RAM interface registers: data (can_ram_data), ID (can_ram_id), and Data Length Code (can_ram_dlc).

    2. Set the RTR bit (can_ram_rtr) to specify the frame type, and set the IDE bit (can_ram_ide) to indicate the frame format.

    3. Set can_ram_rxtx in CAN_RAM_CS to 1, declaring this buffer for transmission.

    4. Write a command to CAN_RAM_CMD to trigger the transfer: set can_ram_dir = 1 (write operation), enable can_ram_buffer_en to activate the corresponding buffer, then set can_ram_start to 1 to initiate the hardware transfer. Upon completion, can_ram_start is automatically cleared by hardware.

    5. The corresponding can_msgx_tx_req in CAN_MBx_STS is set to 1, indicating the message is queued for transmission. Upon successful physical transmission, this bit is cleared and can_msgx_tx_done is simultaneously set to 1.

  2. Reception Flow: After a message passes the CRC check, the Message Processor scans all receive buffers, applying filter and mask logic to find a matching buffer. The payload is stored in the corresponding internal RAM location only if the message is received without errors. The CPU configuration steps are as follows:

    1. Write the desired ID (can_ram_id) and mask (can_ram_id_mask) into the RAM interface registers. For an exact match, all relevant bits in CAN_RAM_MASK should be set to 1.

    2. Configure the RTR and IDE bits and their corresponding mask bits as required.

    3. Clear can_ram_rxtx in CAN_RAM_CS to 0, declaring this buffer for reception.

    4. Write a command to CAN_RAM_CMD to commit the configuration.

    5. Once configured, the corresponding can_msgx_rx_rdy in CAN_MBx_STS is set to 1, indicating hardware readiness. When a new message is successfully matched and received, can_msgx_rx_vld is set to 1, notifying the CPU to read the new data. Simultaneously, the corresponding bit in the global status can_rx_done is asserted, requesting an interrupt to the CPU (if enabled).

Buffer Priority

The CAN controller provides 16 message buffers (MB0 ~ MB15). The priority rules are as follows:

  • Transmit Priority (Tx): Ascending order by buffer number; a smaller number implies higher priority.

  • Receive Priority (Rx): Descending order by buffer number; a larger number implies higher matching and storage priority.

This priority mechanism is entirely independent of message content and is automatically managed by hardware.

FIFO Mode

When the FIFO feature is enabled, the first four message buffers (MB12 ~ MB15) are reserved as a hardware FIFO. The Rx FIFO’s filtering conditions (ID, IDE, RTR, and their masks) inherit from the configuration registers of MB12, and the associated Rx interrupts are triggered based on MB12. The FIFO has the highest priority in all Rx matching scheduling.

The logic block diagram of the Rx FIFO is shown below:

../../../_images/block_of_rx_fifo.svg

CAN_FIFO_STS is used to monitor FIFO status. The state transitions are as follows:

  1. By default, the FIFO is empty (fifo_msg_empty = 1).

  2. When the FIFO successfully receives the first frame, fifo_msg_empty changes to 0, and fifo_msg_lvl increments to indicate the current FIFO depth.

  3. If the FIFO has stored 4 unread frames, fifo_msg_full is set to 1. At this point, no overflow has occurred yet (fifo_msg_overflow = 0).

  4. If a matching frame continues to be received while the FIFO is full, a rolling overwrite strategy is executed: the earliest received data (originally in MB12) is lost, the data in MB13 shifts to MB12, and so on, with the new message stored in MB15. An overflow error is simultaneously triggered (fifo_msg_overflow = 1).

DMA Transfer

The CAN module supports receiving data via DMA. DMA can transfer the contents of message buffers (including arbitration field, control field, and data field) to target memory addresses without CPU intervention.

../../../_images/block_of_rx_dma_in_can.svg

DMA supports two flow control modes: DMA as the flow controller, or CAN as the flow controller. The two modes share identical configuration steps except for the can_rxdma_owner field value in CAN_RXDMA_CFG (0 for DMA, 1 for CAN).

DMA as Flow Controller

When DMA serves as the Flow Controller, the transfer beats are governed by DMA. The configuration steps are as follows:

  1. In CAN_RXDMA_CFG, set can_rxdma_owner = 0 and can_rxdma_src_msize = 1.

  2. In the target message buffer control register CAN_MBx_CTRL, set can_msgx_rxdma_en = 1 to enable the DMA function for that buffer.

  3. In CAN_CTL, set can_rxdma_en = 1 to globally enable the DMA function for CAN.

  4. Configure the DMA parameters: including source address, destination address, transfer direction, block size, and source burst size (src_msize). The src_msize in DMA must match can_rxdma_src_msize in the CAN register.

CAN as Flow Controller

When CAN acts as the flow controller and actively initiates DMA requests, the configuration steps are as follows:

  1. In CAN_RXDMA_CFG, set can_rxdma_owner = 1 and can_rxdma_src_msize = 1.

  2. In the target message buffer control register CAN_MBx_CTRL, set can_msgx_rxdma_en = 1 to enable the DMA function for that buffer.

  3. In CAN_CTL, set can_rxdma_en = 1 to globally enable the DMA function for CAN.

  4. Configure the DMA parameters. The src_msize in DMA must match can_rxdma_src_msize on the CAN side.

Note

  • Each DMA transfer targets only one message buffer.

  • The DMA source burst size (src_msize) must match can_rxdma_src_msize configured on the CAN side.

Error Detection and Management

According to the ISO 11898-1 specification, the Error Confinement mechanism detects communication faults on the bus in real-time and restricts severely faulty nodes from causing continuous interference to the bus network through state degradation.

The overall logic block diagram of error confinement is shown below:

../../../_images/block_diagram_of_error_confinement.svg

Bit Stuffing

CAN signal synchronization relies on edge transitions. If a large number of consecutive bits of the same polarity appear in the data stream, the receiver cannot maintain synchronization. To address this, the protocol introduces bit stuffing:

  • Transmitter: When transmitting a data frame or remote frame, for the fields between SOF and the CRC field, upon detecting five consecutive bits of the same polarity, a stuff bit of the opposite polarity is automatically inserted.

  • Receiver: When receiving a data frame or remote frame, for the fields between SOF and the CRC field, if five consecutive bits of the same polarity are detected, the subsequent opposite-polarity bit is automatically removed. If the 6th bit has the same polarity as the preceding five, a stuff error is flagged.

Fixed-format fields after the CRC field (CRC delimiter, ACK field, and EOF) are not subject to bit stuffing.

Error Types

The CAN supports detection of the following five types of hardware protocol errors:

  • Bit Error: While transmitting a bit, the node monitors (reads back) the actual bus level. If the monitored level differs from the transmitted level (subject to specific exemption rules during the arbitration field or ACK field), a bit error is flagged.

  • Stuff Error: The node detects six consecutive bits of the same polarity, violating the bit stuffing rule.

  • CRC Error: The CRC checksum calculated by the receiver does not match the CRC field data in the received frame.

  • Form Error: A mandatory recessive level is not detected in fixed-format protocol fields (CRC delimiter, ACK delimiter, or EOF).

  • ACK Error: The transmitting node fails to sample any dominant ACK bit from receiving nodes during the ACK slot.

The following table summarizes the detection scope and error frame transmission timing for each error type:

Error Type Summary and Error Frame Transmission Timing

Error Type

Error Cause

Detection Scope

Error Frame TX Timing

Detection Unit

Bit Error

Transmitted level differs from readback

Data/Remote Frame (SOF ~ CRC), Error/Overload Frame flags

Immediately on the next bit

Transmitter

Stuff Error

6 consecutive bits of same polarity

Data/Remote Frame (SOF ~ CRC sequence)

Immediately on the next bit

Receiver

CRC Error

CRC checksum mismatch

Data/Remote Frame (CRC sequence)

After the ACK delimiter

Receiver

Form Error

Mandatory recessive level not detected in fixed-format field

Data/Remote Frame (CRC delimiter, ACK delimiter, first 6 bits of EOF), Error/Overload delimiter

Immediately on the next bit (at the CRC delimiter, treated as CRC error; sent after ACK delimiter)

Transmitter / Receiver

ACK Error

Dominant level not detected in ACK slot

Data/Remote Frame (ACK slot)

After the ACK delimiter

Transmitter

Note

  • A bit error is not flagged under the following conditions: during the ID arbitration phase, transmitting a 1 but reading back a 0 is considered arbitration loss; during the ACK slot, if the transmitter outputs a recessive bit and reads back a recessive level, it is not a bit error; during transmission of a passive error flag, reading back a dominant bit is not a bit error.

  • When a dominant bit is detected on the last bit of the EOF, an overload frame is transmitted instead of an error frame.

Error Detection Scope

According to ISO 11898-1, each error type has a specific detection interval during message transmission and reception.

Error detection scope for a standard data frame during transmission:

../../../_images/error_scope_of_standard_data_frame_in_transmission.svg

Error detection scope for a standard remote frame during transmission:

../../../_images/error_scope_of_standard_remote_frame_in_transmission.svg

Error detection scope for an error frame during transmission:

../../../_images/error_scope_of_error_frame_in_transmission.svg

Error detection scope for a standard data frame during reception:

../../../_images/error_scope_of_standard_data_frame_in_reception.svg

Error detection scope for a standard remote frame during reception:

../../../_images/error_scope_of_standard_remote_frame_in_reception.svg

Error detection scope for an error frame during reception:

../../../_images/error_scope_of_error_frame_in_reception.svg

Error States and Counters

The CAN internally maintains two hardware error counters: Transmit Error Counter (TEC) and Receive Error Counter (REC). These counters dynamically increment or decrement according to protocol rules upon errors or successful transmissions/receptions, representing the current health state of the node.

Counter thresholds directly determine the error state of the node. The state transition diagram is shown below:

../../../_images/error_states.svg

The behavioral characteristics of the three error states are as follows:

  • Error-Active: TEC ≤ 127 and REC ≤ 127. The node participates normally in bus communication. Upon detecting an error, it immediately transmits an active error flag (6 dominant bits).

  • Error-Passive: TEC > 127 or REC > 127. The node can still communicate, but upon detecting an error, it transmits only a passive error flag (6 recessive bits), which does not interfere with other nodes. As a transmitter, an additional 8 recessive-bit Suspend period must be inserted between consecutive transmissions.

  • Bus-Off: TEC > 255. The node is forcibly disconnected from the bus by hardware and cannot transmit or receive any data.

The counting rules for TEC and REC are shown in the following table. Counter changes are triggered at the first bit of the detected error flag. A single message transfer may satisfy multiple conditions simultaneously, and counter values may be adjusted multiple times.

TEC and REC Error Counting Rules

No.

Trigger Condition

TEC

REC

1

Receiver detects an error (except when the receiver detects a bit error during transmission of an active error flag or overload flag).

—

+1

2

The first bit after the receiver finishes sending an error flag is dominant.

—

+8

3

Transmitter sends an error flag.

+8

—

4

Transmitter detects a bit error during transmission of an active error flag or overload flag.

+8

—

5

Receiver detects a bit error during transmission of an active error flag or overload flag.

—

+8

6

Any node detects excessive consecutive dominant bits after sending an error flag or overload flag:

  • 14 consecutive dominant bits after an active error/overload flag;

  • or 8 consecutive dominant bits after a passive error flag;

  • and every additional 8 consecutive dominant bits thereafter.

+8

+8

7

Transmitter successfully transmits a frame (ACK received and no errors until the end of EOF).

If > 0, then -1;

if = 0, unchanged

—

8

Receiver successfully receives a frame (no errors before the ACK slot and dominant ACK bit successfully sent).

—

If 1 ≤ REC ≤ 127, then -1;

if = 0, unchanged;

if > 127, set to 119 ~ 127

9

Bus-Off recovery (128 × 11 consecutive recessive bits detected)

Set to 0

Set to 0

Note

The third item has an exception(TEC unchanged):

  • The transmitter is error-passive, the ACK error occurs because no dominant bit is detected in the ACK slot, and no dominant bit is detected during transmission of the passive error flag.

  • The transmitter sends an error flag due to a stuff error during arbitration (unless the violating bit should have been recessive but was monitored as dominant, in which case TEC still increments by 8).

Bus-Off and Recovery

When TEC exceeds 255, the controller enters the Bus-Off state, and the node cannot transmit or receive any data.

The recovery condition is as follows: the controller must detect 128 occurrences of 11 consecutive recessive bit sequences (i.e., 128 bus idle cycles) while in the Bus-Off state, and only after software actively initiates a recovery request (write CAN_BIT_BUS_ON_REQ of CAN_CTL) will the hardware execute the recovery sequence to switch the node back to the error-active state. The current state can be polled via bus_on_state in CAN_STS.

The Bus-Off and recovery mechanism is shown below:

../../../_images/bus_off_and_bus_off_recovery.svg