cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55 + SGTL5000: No Audio Output Unless Analog Test Mode Enabled (SAI MCLK + I2C Setup)

imium
Associate II

Hello ST Community,

I’m currently testing an SGTL5000 audio codec with the STM32WB55 Nucleo board, and I’ve run into an issue where audio only works when analog test mode is enabled. I’m using the Hathor SGTL5000 audio breakout board from PCBWay (project link).

System Configuration

  • STM32WB55 Nucleo-Board

  • STM32CubeIDE Version: 1.18.1

  • STM32CubeMX Version: 6.14.1

  • SGTL5000 Board: Hathor Breakout (PCBWay project)

  • Connections to SGTL5000:

    • VDDIO, VDDA, VDDD = 1.8V (external LDO)

    • I²C only, pulled up with 4.7 kΩ

    • MCLK = 12 MHz from STM32WB55 via SAI

    • No SCLK, LRCLK, or I²S DIN/DOUT connected

  • Mic connected to MIC_L; HP_L/R used for headphone output


Goal

To establish an internal audio path on the SGTL5000:

MIC → ADC → DAP (optional) → DAC → Headphones

without using I²S (just internal routing).


Problem

  • SGTL5000 only outputs audio when analog test mode is enabled

    CHIP_ANA_TEST1.TESTMODE = 1;
    CHIP_ANA_TEST1.TM_SELECT_MIC = 1;
    CHIP_ANA_TEST1.TM_ADCIN_TOHP = 1;
    CHIP_ANA_TEST1.HP_HOLD_GND = 0;
    CHIP_ANA_TEST1.HP_HOLD_GND_CENTER = 0;
    CHIP_ANA_TEST1.HP_CLASSAB = 1;
    CHIP_ANA_TEST1.HP_I1_ADJ = 2;
    CHIP_ANA_TEST1.HP_IALL_ADJ = 2;
    CHIP_ANA_TEST1.VAG_CLASSA = 0;
    CHIP_ANA_TEST1.VAG_DOUB_CURRENT = 0;​
  • If I disable analog test mode and try internal signal path with DAP/DAC, I get no audio at all.


Observations

  1. I²C wasn’t functional until I enabled MCLK from STM32 SAI block.

  2. Even when MCLK output was selected in CubeMX, it wasn’t enabled in generated code.

  3. I had to manually enable MCLK in MX_SAI1_Init() like this:

hsai_BlockA1.Init.MckOutput = SAI_xCR1_MCKEN;
  • Once MCLK started, I²C communication with SGTL5000 worked fine.

  • Analog test mode gives audible output, confirming that power, mic, and HP output are functional.


What Works

  • MCLK generation from SAI (12 MHz)

  • I²C communication

  • Analog path (mic → headphone) works when analog test mode is enabled

  • Verified power rails at 1.8 V


What’s Not Working

  • Internal SGTL5000 path (ADC → DAC) produces no audio

  • DAP mixer enable/disable doesn’t help

  • Normal SSS/DAP/ANA_CTRL path silent when analog test mode is off


Questions

  1. Is MCLK enough? Does SGTL5000 require LRCLK/SCLK to be present even for internal ADC→DAC path?

  2. Should SGTL5000’s internal DAC clocking work standalone with just MCLK?

  3. Is it valid to use STM32 SAI just for MCLK-only operation?

  4. Am I missing any mandatory SGTL register setups (e.g. DAC volume, headphone mute, etc.)?


Extra Info

  • Breakout board used: Hathor SGTL5000 for ESP32

  • Issue already posted on NXP Community, but no response yet.

  • SGTL5000 registers all respond correctly via I²C.

  • All analog power sections appear functional.

  • Attached Project Archive.

Any suggestions, working examples, or guidance would be greatly appreciated!
Thanks


Umair Jarullah.
Project: STM32WB55 + SGTL5000 codec loopback test (mic → HP)

2 REPLIES 2
Dor_RH
ST Employee

Hello @imium,

3- "Is it valid to use STM32 SAI just for MCLK-only operation?"
==> This is not a typical use case for the SAI peripheral, but it is indeed possible.

As for your other questions about the SGTL5000, unfortunately, I am unable to provide further specific assistance.

However, I would like to understand why you are not considering other solutions available within the STM32Cube Firmware Packages. We offer several ready-to-use audio projects that might be helpful for your application, for which I can bring my help.

I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

Thanks for your contribution.

Dor_RH

 

 

Hello @Dor_RH,

Thanks again for the suggestion — I understand you were referring to the audio examples and supported codec drivers that ship in STM32Cube. Could you please name which Cube “audio solutions” you had in mind (example names, firmware pack, or codec models)? A pointer will help me see the alternative you were thinking of.

That said, I’m committed to using the SGTL5000 for this product because it is low-power, supports internal ADC→DAC routing, and has on-chip DSP — all useful for my power/latency/battery constraints. So I’m not planning to switch to a Cube-provided codec; I only need help on the STM32/SAI side so SGTL5000 works reliably.

A few concrete points / questions:

  1. MCLK & CubeMX codegen — I know where to enable MCLK manually and doing so (for example by setting hsai_BlockA1.Init.MckOutput = SAI_MCK_OUTPUT_ENABLE or hsai_BlockA1.Instance->CR1 |= SAI_xCR1_MCKEN) makes the SGTL5000 responsive and analog test mode audible. My concern is that CubeMX code generation for WB55 still does not enable MCLK by default, so every code regenerate requires reapplying the manual change.

    • What is ST’s recommended, robust pattern to enable MCLK so the change survives CubeMX regenerations? (USER CODE sections, post-init in main(), or another recommended placement?)

    • Which exact HAL macro/field should I use in the current CubeWB package so I use the canonical symbol for WB55 (e.g. is it SAI_MCK_OUTPUT_ENABLE, SAI_xCR1_MCKEN, or another symbol in the latest HAL)?

  2. Example / reference — If there’s a WB55 example in CubeWB (or an ST forum thread) that explicitly enables SAI MCLK, could you point me to it? I’ll copy the canonical approach.

  3. Optional improvement request — If possible, please forward/request that the CubeWB codegen be updated to support automatic MCLK enabling for SAI on WB55 (or at least provide an official guidance snippet), so future projects won’t need a manual patch after code generation.

If it helps I can paste my generated MX_SAI1_Init() here so you can point to the exact line to change. I’ll keep SGTL5000 internals on the codec/vendor side and only need ST confirmation/pattern for SAI/MCLK and code generation.

Thanks again for the time and help,
Umair Jarullah