Configuration

Informative

How to configure the CAN driver, by example. The complete property reference — every field, type, and range — is in Configuration Reference.

The configuration is a set of one or more channels, each with a baudrate configuration and a list of TX/RX mailboxes. The example below defines a single CAN FD channel using the YAML configuration model (the toolchain and file format are implementation-defined).

Minimal single-channel CAN FD configuration

general:
  enable_development_error_reporting: true    # dev-error checks on during development
  enable_set_baud_rate_api: false             # no runtime baudrate switching

config_set:
  - config_set_name: "DefaultConfig"
    channel:
      - channel_id: 0                         # logical channel
        hw_channel: 0                         # maps to the CAN0 peripheral
        tx_processing: "Interrupt"            # TX handled in ISR
        rx_processing: "Interrupt"            # RX handled in ISR
        bus_off_processing: "Polling"         # bus-off polled in Can_CyclicFunction
        input_clock_freq: 80000000            # 80 MHz CAN clock
        baud_rate_config:
          - baud_rate_config_id: 0
            baud_rate: 500                    # 500 kbit/s arbitration phase
            prop_seg: 13
            seg_1: 12
            seg_2: 6
            sync_jump_width: 6
            mode: "CANFD"
            fd_baud_rate_config:
              fd_baud_rate: 2000              # 2 Mbit/s data phase
              tx_bit_rate_switch: true
              prop_seg: 4
              seg_1: 3
              seg_2: 2
              sync_jump_width: 2
        mailbox_config:
          - mailbox_id: 0
            id_type: "Standard"
            hw_object_count: 1
            object_payload_length: "64bytes"
            mailbox_type: "Transmit"
            fd_padding_value: 0xAA
          - mailbox_id: 1
            id_type: "Standard"
            hw_object_count: 4
            object_payload_length: "64bytes"
            mailbox_type: "Receive"
            hw_filter:
              - filter_type: "Basic"
                hw_filter_code: 0x100
                hw_filter_mask: 0x7F0

Key choices explained

  • ``tx_processing`` / ``rx_processing`` / ``bus_off_processing`` independently pick interrupt or polling. Interrupt gives lowest latency; polling avoids ISR wiring and suits small MCUs. Polled events are serviced by API Reference Can_PollFunction (TX/RX) or Can_CyclicFunction (bus-off).

  • Bit timing (prop_seg, seg_1, seg_2, sync_jump_width) is expressed in time quanta relative to input_clock_freq; the arbitration and data phases are timed separately for CAN FD.

  • ``object_payload_length`` must be large enough for your frames; for FD payloads > 8 bytes a fd_padding_value is required (used to fill up to the next valid DLC — see CHI-CAN-MUST-12).

  • RX filtering uses hw_filter_code + hw_filter_mask: an identifier passes when its filtered bits match the code under the mask.

See Configuration Reference for every property, its type, and its full range.