USB Audio Interface Design

Created a project doc

Firmware Starter — U17 STM32G474RET6

View Document

This file is the bring-up baseline for U17 (STM32G474RET6, LQFP-64). Pin mappings below were read from the live schematic. The example targe...
Completed the MCU/UI control block with U17 STM32G474RET6, SWD programming, power/reset support, encoder, four status LEDs, and connections to PD, phantom, preamp, eFuse, and power-good signals. Focused MCU ERC and passive checks are clean.
Open items:
  • New components remain unplaced on the PCB.
  • Local schematic label/wire collisions need a later legibility cleanup.
Firmware setup and the complete GPIO map are in Firmware Starter — STM32G474RET6.
Suggested next steps:
  1. Review full schematic/ERC and resolve remaining system-level issues.
  2. Clean up schematic block arrangement.
  3. Finalize all generic passive MPNs and footprints.
  4. Then transition to PCB constraints and placement.
Review and clean schematic
Run full ERC
Clean schematic layout
Finalize passive BOM
Prepare PCB constraints

Refine this doc
Ask about this doc
Firmware Starter — U17 STM32G474RET6
This file is the bring-up baseline for U17 (STM32G474RET6, LQFP-64). Pin mappings below were read from the live schematic. The example targets STM32CubeIDE / STM32CubeMX with STM32 HAL and is intended to replace the generated Core/Src/main.c (or to be merged into CubeMX USER CODE regions).
Safety: phantom power can damage non-phantom equipment. Firmware starts with PHANTOM_EN_TO_MCU low, holds the THAT5171 in reset, and holds PD_SNK_EN_OD low. It does not enable phantom automatically.
1. Platform and CubeMX configuration
  • MCU: STM32G474RET6, package LQFP64.
  • Toolchain: current STM32CubeIDE with STM32CubeG4 HAL. PlatformIO is also viable with framework = stm32cube, but CubeIDE is the reference because it generates the pin labels and HAL handles used below.
  • Debug: Serial Wire, with SWO enabled if wanted. Do not reclaim PA13, PA14, or PB3.
  • Clock: the schematic has no crystal on U17 PF0/PF1 or PC14/PC15. Select HSI16 as clock source. A simple 16 MHz HSI system clock is adequate for bring-up and avoids inventing an oscillator. The generated 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_DIG
  • pin 2 SWDIO/TMS -> MCU_SWDIO -> U17 PA13
  • pin 4 SWDCLK/TCK -> MCU_SWCLK -> U17 PA14
  • pin 6 SWO/TDO -> MCU_SWO -> U17 PB3
  • pin 10 ~RESET~ -> MCU_NRST
  • pins 3/5 and GNDDetect -> GND
Use an ST-LINK with a keyed 10-pin Cortex cable. VTref is a target reference, not a request to back-power the board.
  1. Open the .ioc in STM32CubeIDE, apply the configuration/labels above, and generate code.
  2. Merge the starter source while preserving CubeMX-generated peripheral init functions.
  3. Build: Project -> Build Project (or make -j in the generated Debug directory).
  4. Power the board normally, connect ST-LINK to J6, select Debug As -> STM32 Cortex-M C/C++ Application.
  5. Use SWD, connect under reset if required, program, reset, and verify the red/blue/green startup indications.
  6. CLI alternative with STM32CubeProgrammer: STM32_Programmer_CLI -c port=SWD mode=UR -w Debug/.elf -v -rst.
7. Bring-up checks
  • Confirm U17 is powered at 3V3_DIG and J6 VTref is near 3.3 V before attaching the debugger.
  • At reset: PHANTOM_EN_TO_MCU low, PREAMP_GAIN_RST_N_TO_MCU low, SPI_PREAMP_CS_N high.
  • Verify I2C ACK at 7-bit 0x28; if absent, hold phantom off and inspect U1/reset/power/strap hardware.
  • Verify THAT5171 CHIP_ID masked by 0xFC equals 0x84 after reset release.
  • Rotate SW1 and verify TIM2 counter changes; press switch and verify active-low PA2.
  • Compare PC0 raw ADC samples against measured PHANTOM_MON_ADC_TO_MCU. Conversion to volts requires the finalized divider transfer ratio; this starter leaves the value raw rather than inventing calibration.
  • Do not enable phantom during initial digital bring-up.
  • 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

Assets

Assets are files uploaded to this project which can be used in various ways.

USB Measurement Audio Interface thumbnail
High-end 2-channel USB Audio Class 2.0 measurement interface for Smaart/REW use, with XMOS digital audio, isolated converter domain, smart encoder/LED UI, precision mic input, DAC line output, loopback ADC, phantom power, and protected USB-C power input.

Properties

Pricing & Availability

Distributor

Qty 1

Arrow

$42.90–$54.90

Digi-Key

$44.09

HQonline

$12.20

LCSC

$169.29–$170.15

Mouser

$163.91

TME

$19.26

Verical

$68.53–$100.51

Controls