User Manual – EG CAN Firmware v1.1

1. Device purpose

This device is a CAN/CAN FD interface based on:

  • Nucleo-G474RE
  • CAN-FD HAT by Embedded Garage

The firmware provides two active protocol modes over USART2:

  • CLI, a text service console
  • SLCAN, an interface compatible with Lawicel/SLCAN class applications

The firmware supports three FDCAN controllers:

  • CAN1
  • CAN2
  • CAN3

2. Startup behavior

  • After a successful start, the application initializes Flash, licenses, system LEDs, inputs, UART, CAN, router, and trigger modules.
  • The default active protocol after boot is CLI.
  • All three CAN buses are initialized during startup.
  • Default rates are 100000 bps for the nominal phase and 1000000 bps for the CAN FD data phase.

Note:

  • CAN command, trigger, and routing configuration is not stored persistently in Flash in this firmware version.
  • Only license data uploaded with the lic command is stored persistently.

3. Host interface

Communication with the host uses USART2:

  • 115200 bps
  • 8 data bits
  • no parity
  • 1 stop bit
  • no flow control

The UART layer uses DMA and buffering:

  • DMA RX: 256 bytes
  • RX buffer: 2048 bytes
  • TX buffer: 2048 bytes
  • CLI command buffer: 256 characters
  • SLCAN command buffer: 64 characters

4. Hardware elements

4.1 12V inputs

Four digital 12V inputs are available:

  • I1
  • I2
  • I3
  • I4

The inputs are active high and use 50 ms software debounce.

4.2 Buttons

Six buttons are available:

  • SW1
  • SW2
  • SW3
  • SW4
  • SW5
  • SW6

Buttons are active low and use 50 ms debounce.

In the current application version, only this one is used directly:

  • SW1: switch active protocol

SW3-SW6 can be used by the inp_trig function as button trigger sources.

4.3 Relay outputs

Four relay outputs are available:

  • Q1
  • Q2
  • Q3
  • Q4

In the current firmware version, Q1-Q4 do not indicate CLI/SLCAN mode. They are intended for relay trigger functionality if configured by a CLI command and enabled by the corresponding license.

4.4 System LEDs

The board has system LEDs:

  • RDY
  • BUSY

RDY LED meaning:

  • startup: 1000 ms ON / 200 ms OFF pattern
  • normal operation: steady ON
  • warning: 500 ms ON / 500 ms OFF
  • critical error: 100 ms ON / 100 ms OFF

BUSY LED meaning:

  • driven by a pattern corresponding to the current protocol. According to the number of pulses:
    • 1: CLI control (console)
    • 2: SLCAN/LAWICEL protocol

Additionally, each CAN bus has separate RX and TX LEDs driven by frame activity.

5. CAN buses

Firmware supports:

  • Classic CAN
  • CAN FD
  • CAN FD with BRS
  • standard 11-bit and extended 29-bit identifiers
  • DATA and RTR frames

Default startup rates for CAN1, CAN2 and CAN3:

  • nominal bitrate: 100000 bps
  • CAN FD data bitrate: 1000000 bps

Available nominal bitrates:

  • 1000
  • 2000
  • 5000
  • 10000
  • 20000
  • 50000
  • 100000
  • 125000
  • 250000
  • 500000
  • 1000000

Available CAN FD data bitrates:

  • 1000000
  • 2000000
  • 4000000
  • 5000000
  • 8000000

CAN buffers and queues:

  • RX queue: 16 frames per interface
  • TX queue: 16 frames per interface
  • standard filters: 28 entries
  • extended filters: 8 entries

By default, frame forwarding to the console is enabled for all three buses. CAN-to-CAN forwarding is disabled by default.

6. Operating modes

6.1 CLI

CLI is active after startup. The user communicates through a serial terminal and enters text commands terminated with Enter.

Commands available in CLI:

  • help [command] – list commands or details for a selected command
  • can_tx <bus> <id_hex> <S|E> <D|R> <C|F|B> <len> [data_hex] – send a CAN or CAN FD frame
  • can_status – status of all buses, forwarding, bitrate and listen-only
  • can_en <bus> <E|D> – enable or disable a bus
  • can_silent <bus> <E|D> – enable or disable listen-only
  • can_fwd_set <source_bus> <target_bus> <0|1> – CAN-to-CAN or CAN-to-active-protocol routing, where target_bus = 0 means protocol
  • can_speed <bus> <bitrate> – set nominal bitrate
  • can_fd_speed <bus> <bitrate> – set CAN FD data phase bitrate
  • can_filter <bus> <idx> <M|R|D> <id1_hex> <id2_hex> <S|E> <R|N|A> – configure CAN filter
  • can_filters_get <bus> – read filter list
  • rly_trig <relay> <bus> <S|C|T|P> <id_hex> <S|E> <len> <D|R> <C|F|B> <mask_hex> <value_hex> [duration_ms] – configure relay control based on CAN frame
  • rly_trig_get <relay> – read relay trigger configuration
  • inp_trig <input> <R|F|H> <interval_ms> <bus> <id_hex> <S|E> <D|R> <C|F|B> <len> [data_hex] – send CAN frame on input event
  • inp_trig_dis <input> [R|F|H] – disable input trigger
  • inp_trig_get – read input trigger configuration
  • lic <idx> <hash64> – write license hash to Flash
  • lic_get – device UID, license slot contents, and active feature status

Abbreviations in CLI:

  • S and E mean standard or extended identifier
  • D and R mean DATA or RTR
  • CFB mean Classic CAN, CAN FD, and CAN FD with BRS
  • in can_filterM = mask, R = range, D = dual, and actions are R = reject, N = none, A = accept
  • in rly_trigS = set, C = clear, T = toggle, P = pulse
  • in inp_trigR = rising, F = falling, H = hold

CLI command examples:

  • help
  • help can_tx
  • can_tx 1 1F0 S D C 8 1122334455667788
  • can_tx 3 123 S D B 12 00112233445566778899AABB
  • can_speed 1 500000
  • can_fd_speed 1 2000000
  • can_en 2 D
  • can_silent 2 E
  • can_fwd_set 1 2 1
  • can_fwd_set 2 0 1
  • can_filter 1 0 M 123 7FF S A
  • lic_get

CLI limitations in current code:

  • can_filter requires an active Extended CAN filters license
  • rly_trig* functions require an active CAN relay trigger license
  • inp_trig* functions require an active CAN button trigger license
  • there is no separate command to store current runtime configuration to Flash

6.2 SLCAN

SLCAN is the second active router protocol. Protocol is switched with SW1.

SLCAN is connected only to:

  • CAN1

Supported SLCAN parser commands:

  • O – open CAN1
  • C – close CAN1
  • Sx – set nominal bitrate for CAN1
  • Yx – set CAN FD data phase bitrate for CAN1
  • tT – transmit classic DATA frames
  • rR – transmit classic RTR frames
  • dD – transmit CAN FD without BRS
  • bB – transmit CAN FD with BRS

SLCAN bitrate mapping:

  • S0 = 10000
  • S1 = 20000
  • S2 = 50000
  • S3 = 100000
  • S4 = 125000
  • S5 = 250000
  • S6 = 500000
  • S8 = 1000000

SLCAN CAN FD data bitrate mapping:

  • Y1 = 1000000
  • Y2 = 2000000
  • Y4 = 4000000
  • Y5 = 5000000
  • Y8 = 8000000

Example SLCAN frames and commands:

  • O – open CAN1 for operation in SLCAN mode
  • C – close CAN1
  • S6 – set CAN1 nominal speed to 500000 bps
  • Y2 – set CAN FD data phase speed to 2000000 bps
  • t12381122334455667788 – standard Classic CAN DATA frame with ID 0x123, length 8 bytes, and data 11 22 33 44 55 66 77 88
  • T1ABCDEFF411223344 – extended Classic CAN DATA frame with ID 0x1ABCDEFF, length 4 bytes, and data 11 22 33 44
  • r3210 – standard RTR frame with ID 0x321 and length 0
  • R1ABCDEFF8 – extended RTR frame with ID 0x1ABCDEFF and length 8
  • d123CAA55AA55AA55AA55AA55 – standard CAN FD frame without BRS, ID 0x123, DLC C meaning 24 data bytes; after DLC, 48 hex characters are required
  • D1ABCDEFF9AABBCCDDEEFF001122334455 – extended CAN FD frame without BRS, ID 0x1ABCDEFF, DLC 9 meaning 12 data bytes
  • b1239AABBCCDDEEFF001122334455 – standard CAN FD frame with BRS, ID 0x123, DLC 9 meaning 12 data bytes
  • B1ABCDEFFA00112233445566778899AABBCCDDEEFF – extended CAN FD frame with BRS, ID 0x1ABCDEFF, DLC A meaning 16 data bytes

Transmit frame format description:

  • t and r mean standard 11-bit ID
  • T and R mean extended 29-bit ID
  • d and D mean CAN FD without BRS
  • b and B mean CAN FD with BRS
  • after ID there is a single DLC character in hex format
  • for Classic CAN frames, DLC 0-8 equals the number of data bytes
  • for FD frames, parser DLC mapping follows CAN FD standard: 9=12A=16B=20C=24D=32E=48F=64 bytes
  • RTR frames do not include a data field after DLC
  • all commands must end with CR or LF

SLCAN limitations in this version:

  • only CAN1 is handled by the SLCAN parser (protocol limitation)
  • only non-FD frames up to 8 bytes are reported to the host
  • commands FMmVNs are recognized by the parser but do not provide full end-user functionality
  • outgoing host frames include a timestamp in ms sent modulo 0xFFFF

7. Licenses

The license system uses the MCU UID and stores 32-byte SHA-256 hashes in user Flash.

Licensed features:

  • Extended CAN filters
  • CAN relay trigger
  • CAN button trigger

The Store config function (saving configuration to non-volatile memory) is under preparation.

8. Trigger features

8.1 Relay trigger

Each Q1-Q4 relay can react to a matching CAN frame.

Available modes:

  • ON/OFF
  • TOGGLE
  • PULSE with duration in milliseconds

Matching includes:

  • bus number
  • CAN identifier
  • standard or extended ID type
  • RTR or DATA
  • Classic CAN or CAN FD
  • BRS
  • data length
  • data mask and value

8.2 Input trigger

Inputs and buttons can send a configured CAN frame on event:

  • rising (button press / applying 12V signal)
  • falling (button release / signal release)
  • hold with periodic interval – sent while the button is held or while 12V is present on one of the Ix inputs

Input mapping for inp_trig command:

  • I1 to I4
  • B3 to B6 for SW3-SW6 buttons

Input mapping for inp_trig_dis command:

  • I1 to I4
  • B3 to B6 for SW3-SW6 buttons

9. Quick start

  1. Connect Nucleo-G474RE and CAN-FD HAT.
  2. Drag the .hex file to the virtual USB drive.
  3. Open terminal at 115200 8N1.
  4. After startup, run help.
  5. Check interface status with can_status.
  6. If needed, set speeds using can_speed and can_fd_speed.
  7. Send a test frame with can_tx.
  8. To switch to SLCAN, press SW1 and use Lawicel-compatible commands on CAN1. You can then use other software, for example Savvy CAN.

10. Diagnostics

  • No UART communication:
    • check 115200 8N1
    • check USART2 connection
    • check whether host sends CR or LF line endings
  • No CAN frames:
    • check 120 Ohm termination
    • check bitrate match on both bus sides
    • check can_status
    • check whether bus is in can_silent mode
    • check whether interface was disabled with can_en <bus> D
  • No relay trigger or input trigger reaction:
    • check lic_get
    • confirm required license is active
    • check ID, frame type, length, and masked data match
  • Incomplete SLCAN support:
    • expected in this version due to CAN1-only support and missing full implementation of FMmVNs