Firmware Configuration Readout

MMC / sensorless FOC

STM32G474RE + X-NUCLEO-IHM16M1 (STSPIN830) motor bring-up firmware. Field-oriented control instrumented end-to-end over the mmc-proto link.

build release · MS6
target thumbv7em-none-eabihf
fw mmc-g474 · date 2026-07-13
Flash used
5.1%
26.7 / 512 KB
Static RAM
26.9%
34.4 / 128 KB
Core clock
170MHz
Cortex-M4F · single
Control rate
20kHz
50 µs ISR window

Resource Utilization measured from release ELF · arm-none-eabi-size

FLASH  0x08000000 · 512 KB (dual bank)26.7 KB  /  5.1%
0128256384512 KB
.text 24.8 KB · .rodata 1.2 KB · .vectors 472 B · .data init 272 B — the entire Embassy + HAL + FOC + observer + protocol stack.
RAM (static)  0x20000000 · 128 KB34.4 KB  /  26.9%
0326496128 KB
BURST profiler buffer · 32 KB all other static · 2.4 KB free for stack / growth · ~93 KB
One [f32; 4096·2] capture buffer is 93% of static RAM. It only holds (i_d, v_d) pairs during an R/L probe — gate it behind a feature and the resident footprint drops to ~2.4 KB. No heap: allocation is fully static, single executor thread, panic-halt.

Platform & Build

MCU
STM32G474RE
Core
Cortex-M4F @170 MHz
Clock tree
HSI16 /4 ×85 /2
Flash
512 KB dual-bank
RAM
128 KB
Framework
Embassy async
embassy-stm32
0.6.0
Runtime
no_std · no alloc
Profile
LTO · cg-units 1 · O2
Runner
probe-rs

Control & Front-End

PWM
TIM1 center-aligned
Carrier
20 kHz ARR 4250
Loop rate
20 kHz 50 µs
Max duty
0.85
ADC
ADC1 42.5 MHz
Sensing
3× shunt, injected
Shunt
0.33 Ω 0.504 V/A
VBUS
÷ divider ×16
Link
LPUART1 VCP
Baud
1 Mbaud COBS

Motor Characteristics Stage F0 bench fit

ParameterValueConfidence
Pole pairs p7fixed
Stator R Rs1.00 Ωlocked-rotor
Apparent R R'0.97 Ωrotating fit
Stator L Ls0.10 mHdesign center
Flux linkage λ0.894 mWb±0.04
Inertia J0.31 µN·m·s²rough
Friction0.8 mN·mest.
L was ill-conditioned in the rotating sweep (0.05 ± 0.10 mH — the I-f hang angle near π/2 hides it); 0.1 mH is a robust center that only sets the current-PI zero. J is the least-trusted number, so the speed loop is tuned conservatively.

Tuning Setup

Current loop · pole-zero
Bandwidth
1 kHz rad/s ω
Kp = L·ω
0.10
Ki = R·ω
1000
Speed loop
bw
40 rad/s el
Kp
2.0e-4
Ki
2.0e-3
i_q limit
±0.8 A
Sensorless
Observer
flux + PLL
I-f handoff
150 rad/s el

Drive Modes

0
Off
Stage disabled, phases Hi-Z
1
Open-loop voltage
Forced-frame V·∠ωet { volts, omega_e }
2
I-f current
Forced-frame current, i_q live-adjustable { amps, omega_e }
3
Sensorless ← closed loop
I-f start → blend → observer + speed loop { amps, omega_e }
4
R/L probe
Locked-rotor identification (bench test)
State channel:
OFF RUN FAULT_OC FAULT_DRV FAULT_VBUS CAL SL_RAMP SL_BLEND

Profiler / Auto-Tune MS6

Measure → fit → write back, entirely over the protocol. The R/L probe aligns the rotor, square-wave excites the d-axis, and captures every ISR tick at full 20 kHz into the burst buffer; the host fits R/L and pushes new gains back live.

Align time
300 ms
Excitation ½-period
1.6 ms · 32 tk
Capture
4096 pairs @20 kHz
Records
i_d, v_d
Live-writable parameters (RAM)
rlflux cur_bwspeed_kpspeed_ki
Each write is range-checked before it reaches the loop; a new value applies at the next clean drive start.

Protection & Limits

Overcurrent trip
1.5 A · 2 samples
VBUS window
5 – 30 V
Driver fault
EN_FAULT open-drain
Deadman
2.0 s silence
Boot cal
8192 tk · 0.41 s
V amplitude
≤ 3.0 V
I amplitude
≤ 1.0 A
ωe ceiling
2000 rad/s
Slew ω · V · I
500 · 5 · 2

Telemetry

Channels
18
Stream default
1 kHz ÷20
Transport
COBS / mmc-proto
Burst capture
20 kHz i_d, v_d
ISR watchdog
ISR_MAX_CYCLES
Live channels
iq_refi_di_q v_dv_q duty_aduty_bduty_c omega_mtheta_evbus i_ai_bi_c state theta_estomega_esttheta_err
Observer estimates (highlighted) stream alongside their measured counterparts, so every capture doubles as a shadow-validation of the sensorless stack.