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
liccommand 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 commandcan_tx <bus> <id_hex> <S|E> <D|R> <C|F|B> <len> [data_hex]– send a CAN or CAN FD framecan_status– status of all buses, forwarding, bitrate and listen-onlycan_en <bus> <E|D>– enable or disable a buscan_silent <bus> <E|D>– enable or disable listen-onlycan_fwd_set <source_bus> <target_bus> <0|1>– CAN-to-CAN or CAN-to-active-protocol routing, wheretarget_bus = 0means protocolcan_speed <bus> <bitrate>– set nominal bitratecan_fd_speed <bus> <bitrate>– set CAN FD data phase bitratecan_filter <bus> <idx> <M|R|D> <id1_hex> <id2_hex> <S|E> <R|N|A>– configure CAN filtercan_filters_get <bus>– read filter listrly_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 framerly_trig_get <relay>– read relay trigger configurationinp_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 eventinp_trig_dis <input> [R|F|H]– disable input triggerinp_trig_get– read input trigger configurationlic <idx> <hash64>– write license hash to Flashlic_get– device UID, license slot contents, and active feature status
Abbreviations in CLI:
SandEmean standard or extended identifierDandRmean DATA or RTRC,F,Bmean Classic CAN, CAN FD, and CAN FD with BRS- in
can_filter:M= mask,R= range,D= dual, and actions areR= reject,N= none,A= accept - in
rly_trig:S= set,C= clear,T= toggle,P= pulse - in
inp_trig:R= rising,F= falling,H= hold
CLI command examples:
helphelp can_txcan_tx 1 1F0 S D C 8 1122334455667788can_tx 3 123 S D B 12 00112233445566778899AABBcan_speed 1 500000can_fd_speed 1 2000000can_en 2 Dcan_silent 2 Ecan_fwd_set 1 2 1can_fwd_set 2 0 1can_filter 1 0 M 123 7FF S Alic_get
CLI limitations in current code:
can_filterrequires an active Extended CAN filters licenserly_trig*functions require an active CAN relay trigger licenseinp_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 CAN1C– close CAN1Sx– set nominal bitrate for CAN1Yx– set CAN FD data phase bitrate for CAN1t,T– transmit classic DATA framesr,R– transmit classic RTR framesd,D– transmit CAN FD without BRSb,B– transmit CAN FD with BRS
SLCAN bitrate mapping:
S0= 10000S1= 20000S2= 50000S3= 100000S4= 125000S5= 250000S6= 500000S8= 1000000
SLCAN CAN FD data bitrate mapping:
Y1= 1000000Y2= 2000000Y4= 4000000Y5= 5000000Y8= 8000000
Example SLCAN frames and commands:
O– open CAN1 for operation in SLCAN modeC– close CAN1S6– set CAN1 nominal speed to 500000 bpsY2– set CAN FD data phase speed to 2000000 bpst12381122334455667788– standard Classic CAN DATA frame with ID0x123, length 8 bytes, and data11 22 33 44 55 66 77 88T1ABCDEFF411223344– extended Classic CAN DATA frame with ID0x1ABCDEFF, length 4 bytes, and data11 22 33 44r3210– standard RTR frame with ID0x321and length 0R1ABCDEFF8– extended RTR frame with ID0x1ABCDEFFand length 8d123CAA55AA55AA55AA55AA55– standard CAN FD frame without BRS, ID0x123, DLCCmeaning 24 data bytes; after DLC, 48 hex characters are requiredD1ABCDEFF9AABBCCDDEEFF001122334455– extended CAN FD frame without BRS, ID0x1ABCDEFF, DLC9meaning 12 data bytesb1239AABBCCDDEEFF001122334455– standard CAN FD frame with BRS, ID0x123, DLC9meaning 12 data bytesB1ABCDEFFA00112233445566778899AABBCCDDEEFF– extended CAN FD frame with BRS, ID0x1ABCDEFF, DLCAmeaning 16 data bytes
Transmit frame format description:
tandrmean standard 11-bit IDTandRmean extended 29-bit IDdandDmean CAN FD without BRSbandBmean CAN FD with BRS- after ID there is a single DLC character in hex format
- for Classic CAN frames, DLC
0-8equals the number of data bytes - for FD frames, parser DLC mapping follows CAN FD standard:
9=12,A=16,B=20,C=24,D=32,E=48,F=64bytes - 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
F,M,m,V,N,sare 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
Ixinputs
Input mapping for inp_trig command:
I1toI4B3toB6for SW3-SW6 buttons
Input mapping for inp_trig_dis command:
I1toI4B3toB6for SW3-SW6 buttons
9. Quick start
- Connect Nucleo-G474RE and CAN-FD HAT.
- Drag the
.hexfile to the virtual USB drive. - Open terminal at 115200 8N1.
- After startup, run
help. - Check interface status with
can_status. - If needed, set speeds using
can_speedandcan_fd_speed. - Send a test frame with
can_tx. - 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_silentmode - 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
- check
- Incomplete SLCAN support:
- expected in this version due to CAN1-only support and missing full implementation of
F,M,m,V,N,s
- expected in this version due to CAN1-only support and missing full implementation of

