Showing results for 
Search instead for 
Did you mean: 

CODEC with STM32



I would like to know how to retrieve the acquisition values ​​: INPUT -> ADC -> SAI -> µP like the diagram below :


I have a program that works for this : DMA -> SAI -> DAC But this is not the way I would have wanted to make my CODEC work. Do you have any idea how should i proceed ? Thanks in advance

ST Employee

some STM32 example(s) and application(s) may be a good reference.

for example, AN3997 Audio playback and recording using the STM32F4DISCOVERY


I saw but it does not correspond to what I want to do, it takes the recordings via an SD card and goes through a DAC and then the HP which does not correspond to what I am looking for. If you have an example of the taking into account of the microphone via ADC and SAI via the microprocessor that would interest me

ST Employee

what audio codec you use?

if you also use AUDIO_CODEC WM8994 (or a similar one), stm32h743i_eval_audio.c may be a good reference: SAI and record.

STM32CubeH7/Drivers/BSP/STM32H743I-EVAL/stm32h743i_eval_audio.c at master · STMicroelectronics/STM32CubeH7 · GitHub

I use CODEC SGTL5000 (but it's the same principle except for a few details). I can see the example but 
I do not see where is the part of code that interests me and the configuration under CUBEMX.

Besides, why go looking for an example of another evaluation board with another CODEC or I have an STM32L552E-EV evaluation board with a CODEC on this board already.

ST Employee

I suppose CODEC SGTL5000 not used by STM32 boards (from ST).

if you want to start from STM32L552E-EV evaluation board, on which codec CS42L51 used, in similar way, BSP driver is stm32l552e_eval_audio.c, component driver is cs42l51.c.

Hi jiangfan, 

Thank you for this link but where is what is the code where it uses the CODEC to retrieve the values ​​via an ADC ? I've explored all examples of this CODEC with this card and haven't seen a single place where one can retrieve the data via an ADC.

Thank you for your helps.


in this L552 example is:

+ Call the function BSP_EVAL_AUDIO_IN_Record() to record audio stream. The recorded data are stored to user buffer in raw
        (L, R, L, R ...).
        Instance : Select the input instance. Can be 0 (SAI) or 1 (DFSDM).

SAI input is from codec ADC ... so what is the problem ??

ST Employee

as you mentioned, path is INPUT -> ADC -> SAI -> µP.

for codec CS42L51 on STM32L552E-EV evaluation board, BSP_AUDIO_IN_Init(), BSP_AUDIO_IN_Record() should be the functions to follow.  Instance : Select the input instance. Can be 0 (SAI)

Yes jiangfan this is the case for INPUT -> ADC -> SAI -> µP. In this cas I use the link that you give me before

Or I can find in the example provided by stmicroelectronics ? But the function BSP_AUDIO_IN_Record(), I can use a microphone to record my voice for example and where is the .ioc configuration file that goes with this project ?