cancel
Showing results for 
Search instead for 
Did you mean: 

CODEC with STM32

DYann.1
Senior II

Hello,

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

DYann1_0-1692602441481.png

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

30 REPLIES 30

You may walk around the github repo for STM32CubeL5 to find the example/application/Demonstration regarding audio recording. if you are familiar with STM32Cube architecture, you may find what you want easily.

STM32L552E-EV/Demonstrations should fit your requirements:

https://github.com/STMicroelectronics/STM32CubeL5/tree/master/Projects/STM32L552E-EV/Demonstrations/Demo
- An audio recorder sub-module provides a complete audio record solution and delivers a high-quality
record experience. It supports record in WAV format at 44.1khz sample rate in mono. The recorded file
rec.wav is saved on the SD card (it is overwritten at each new record).

SAI_AudioPlay example may be useful too (simpler)
https://github.com/STMicroelectronics/STM32CubeL5/tree/master/Projects/STM32L552E-EV/Examples/SAI/SAI_AudioPlay

Hi jiangfan,

Thank you for your advices but this looks a lot like the examples provided by STmicro. I have already done these tests. In one case it is necessary to load the pieces of music in a memory zone of the STM32 and then it diffuses the sound via the headphones. In the other I have not found anything that really corresponds to what I am looking for.

jiangfan
ST Employee

you mentioned you have STM32L552E-EV board. Have you tried the STM32L552E-EV Demonstration? the STM32L552E-EV Demonstration contains different modules including Audio module: inside Audio module, two audio solutions with an audio recorder sub-module - this should be feature that you need.

in my opinion, you have everything needed: the STM32L552E-EV board, the FW from ST. you just need to do test with STM32L552E-EV Demonstration, and port part of Demonstration to your application. and these are enough.

Hi jiangfan, 

Thank you for your answer, yes I tried the STM32L552E-EV Demonstration, there is no '.ioc' configuration file and how to use the sub-module audio recorder if we don't have the .ioc in the Project ? 

Do you have a specific example with code ? I uploaded the project to Github with your link and I don't see the difference with the examples provided by ST ?

DYann1_0-1693161630963.png

jiangfan
ST Employee

in my opinion, .ioc file will provide some convenience when starting work with STM32CubeMX, but .ioc file is not mandatory. Take STM32L552E-EV Demonstration as example, there is no '.ioc' configuration file, but all GPIO and clock configuration are in the source files, .h for GPIO and .c for clock setting in the package. from .ioc file, STM32CubeMX may automatically generate .h/.c files, user may also re-use the existing .h/.c files to implement needed features.

Hi jiangfan, 

Thank you for this information but after me, It's easier to have the .ioc configuration file than the opposite. Now after downloading the demo project on my card I have this screen and do you know how to proceed for the registration ? 

DYann1_0-1693291596965.png

I have this information below, but how to register ? It probably saves on the SD card on the evaluation board ?

DYann1_2-1693291674625.png

MM..1
Chief II

Hi boys, ioc files and all MX is big help from ST, but too big issue. I agree, that examples without ioc is ...
But when anybody create custom board with slightly other chip as example , then need create new ioc from scratch.
And @DYann.1 for some hw based peripherals as SAI is, you in code found only init and one line code to start record. I recommend you try create own project from start and use or create only BSP file for chips around STM.

I agree with you that it is better to have the .ioc configuration file. but you cannot imagine to see .ioc configuration file for each project of STM32 cube FW package, like the case of STM32L552E-EV/Demonstration.

sorry, I don't understand what you mean "how to proceed for the registration".

STM32L552E-EV/Demonstration readme.txt clearly mentions:

- An audio recorder sub-module provides a complete audio record solution and delivers a high-quality
record experience. It supports record in WAV format at 44.1khz sample rate in mono. The recorded file
rec.wav is saved on the SD card (it is overwritten at each new record).

which means you have to plug a SD card into the SD card slot before you start a recording.

Hi jiangfan,

Yes I put in the SD card. I understand that the file is saved on the SD card. But what do we record with? A mic ? A frequency generator ? I'm not sure that the card has a microphone on it,

DYann1_0-1693378385661.png

Do we use the headset microphone to record sound ? And how to play back the sound we recorded ? Can we play back the .wave file directly via the evaluation board ?

If I understand correctly, yes, we use the headset microphone to record sound, and play back the sound we recorded to the headset.

NOTE: headphone jack is CTIA type, so CTIA type (instead of OMTP type) headphone with microphone should be used.