Skip to main content
Associate
April 11, 2026
Solved

STM32F411E-DISCOVERY - audio filtering

  • April 11, 2026
  • 5 replies
  • 349 views

I’m starting to work with the STM32F411E‑Discovery board and I’d like to use it for real‑time audio filtering. I’m using the onboard MEMS microphone together with the mini‑jack audio output.

I’m currently struggling with configuring the clock settings correctly — I’m observing a variable timing drift between the microphone input and the audio output.

Could you advise on the proper clock configuration for this setup, or point me to an existing project or example that demonstrates real‑time audio processing on the STM32F411E‑Discovery?

Best answer by MOBEJ

Hello @Michael9 , 

There are 2 sub-demos in the BSP example for the STM32F411E-Discovery board:

  • AudioPlay_Test
  • AudioRecord_Test

You can find these examples by downloading the STM32Cube MCU Package for STM32F4 series from ST.com using this link: STM32CubeF4 package ,

After downloading, go to the following path: Firmware\Projects\STM32F411E-Discovery\Examples\BSP

There you will find the exact projects that can help you test the audio functionality on this specific board, STM32F411E-Discovery.

Br

5 replies

mƎALLEm
ST Technical Moderator
April 11, 2026

Hello @Michael9 and welcome to the ST community,

Why don't use the BSP driver of the board especially the audio driver avalable in CubeF4 package / BSP: https://github.com/STMicroelectronics/32f411ediscovery-bsp/blob/c7de631adeb20ecd2097581ab22e88d316a8bdb3/stm32f411e_discovery_audio.c ?

Look at the demo example provided in the STM32CubeF4 package: Projects\STM32F411E-Discovery\Applications\Audio\Audio_playback_and_record especially the audio recording management implementation in waverecorder.c file.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
MOBEJ
MOBEJBest answer
ST Employee
April 13, 2026

Hello @Michael9 , 

There are 2 sub-demos in the BSP example for the STM32F411E-Discovery board:

  • AudioPlay_Test
  • AudioRecord_Test

You can find these examples by downloading the STM32Cube MCU Package for STM32F4 series from ST.com using this link: STM32CubeF4 package ,

After downloading, go to the following path: Firmware\Projects\STM32F411E-Discovery\Examples\BSP

There you will find the exact projects that can help you test the audio functionality on this specific board, STM32F411E-Discovery.

Br

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Michael9Author
Associate
April 14, 2026

Hello,

Thank you for the very fast response. I tried using the example you mentioned, but I noticed a problem.

I want to run sound recording and playback simultaneously in a continuous loop.

I used the BSP example, but it seems that the recording and playback use different timing settings. As a result, I am getting a variable drift between the recorded and the played sound.

mƎALLEm
ST Technical Moderator
April 14, 2026

Check you have the same clock configuration of the example: the same clock dividers, the same clock source etc ...

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Visitor
August 2, 2026

If the sample rates match but you're still seeing a gradual drift, it's often caused by the input and output not sharing the same audio clock domain. Even a tiny mismatch (for example, 48,000 Hz vs. 47,998 Hz) accumulates over time.

A few things you could check:

  • Verify both the MEMS microphone and the audio codec are running from the same PLL/I2S clock configuration.
  • Compare the actual sample rate configured for recording and playback, not just the nominal value.
  • Make sure DMA buffer sizes and interrupt timing are identical for both paths.
  • If you're building a continuous full-duplex pipeline, consider using a circular/ring buffer with occasional sample insertion or removal to compensate for long-term clock drift.

If your goal is simply to prototype the filtering algorithm rather than debug the STM32 clocking, it can also be useful to test the DSP logic first in a browser-based audio playground. That lets you validate filters and EQ settings before deploying them to the board. I sometimes use https://soniclab.io/tools/bass-booster for quickly experimenting with bass filters and frequency adjustments before implementing similar processing on embedded hardware.

Out of curiosity, are you using the CS43L22 codec over I2S in full-duplex mode, or are the microphone input and playback running through separate interfaces?