USB Audio Interface Design
Firmware Starter — U17 STM32G474RET6
Core/Src/main.c (or to be merged into CubeMX USER CODE regions).Safety: phantom power can damage non-phantom equipment. Firmware starts withPHANTOM_EN_TO_MCUlow, holds the THAT5171 in reset, and holdsPD_SNK_EN_ODlow. It does not enable phantom automatically.
STM32G474RET6, package LQFP64.framework = stm32cube, but CubeIDE is the reference because it generates the pin labels and HAL handles used below.SystemClock_Config() may later use the PLL, but keep SPI1 at or below 10 MHz.SYS: Debug = Serial Wire (or Trace Asynchronous SW if PB3/SWO is used).I2C1: PB6 = SCL and PB7 = SDA, 100 kHz initially, 7-bit addressing. External 4.7 kΩ pull-ups R2/R1 already connect both nets to 3V3_DIG. Enable analog filter. Generate handle hi2c1.SPI1: full-duplex master, PA4 software GPIO chip select, PA5 SCK, PA6 MISO, PA7 MOSI; 8-bit, MSB first, CPOL low / CPHA first edge (mode 0), software NSS. Choose a prescaler giving SCLK 3V3_DIGMCU_SWDIO -> U17 PA13MCU_SWCLK -> U17 PA14MCU_SWO -> U17 PB3~RESET~ -> MCU_NRSTGND.ioc in STM32CubeIDE, apply the configuration/labels above, and generate code.make -j in the generated Debug directory).STM32_Programmer_CLI -c port=SWD mode=UR -w Debug/.elf -v -rst.3V3_DIG and J6 VTref is near 3.3 V before attaching the debugger.PHANTOM_EN_TO_MCU low, PREAMP_GAIN_RST_N_TO_MCU low, SPI_PREAMP_CS_N high.0x28; if absent, hold phantom off and inspect U1/reset/power/strap hardware.0xFC equals 0x84 after reset release.PHANTOM_MON_ADC_TO_MCU. Conversion to volts requires the finalized divider transfer ratio; this starter leaves the value raw rather than inventing calibration.1. Platform and CubeMX configuration
Required CubeMX user labels
2. Complete U17 pin table (live schematic)
3. Peripheral/protocol notes
STUSB4500 over I2C1
THAT5171 over SPI1
4. Cohesive `main.c` starter
GPIO initialization requirements
5. Safe startup sequence
6. Build and flash through J6 SWD
7. Bring-up checks