cancel
Showing results for 
Search instead for 
Did you mean: 

Is the initialization code generated from STM32CubeMX intended to work with the wm8994 audio codec?

misterstarshine
Associate III
Posted on September 15, 2016 at 16:19

Hi.

I've used STM32CubeMX to generate initialization code for stuff on my STM32F746G-Discovery board. I guess the clock settings are correctly initiated for the onboard audio codec (wm8994). Other settings for the SAI module are in the function MX_SAI2_Init.

I have no clue how to output audio though. I've tried to output audio by using the HAL_SAI_Transmit_DMA and HAL_SAI_Transmit functions but no audio seems to be generated.

Is the function MX_SAI2_Init designed to work specifically with the wm8994 codec or just any codec hooked to the SAI interface? Do I need to do something more to actually output an audio buffer to the interface?

3 REPLIES 3
slimen
Senior
Posted on September 15, 2016 at 17:00

Hi j.tobbe,

The initialization code generated from CubeMX should be work!

Please share your code to identify what is going wrong and precise which CubeMx and firmware version used.

Have a look to the SAI-Audio example in the

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef7.html

package, referred to this path: STM32Cube_FW_F7_V1.4.0\Projects\STM32756G_EVAL\Examples\SAI\SAI_Audio

This example provides basic implementation of audio features using the audio codec WM8994.

You can compare your generated code with this working application, then merge the functions you need. 

Refer to the

http://www.st.com/content/ccc/resource/technical/document/user_manual/f0/14/c1/b9/95/6d/40/4d/DM00190424.pdf/files/DM00190424.pdf/jcr:content/translations/en.DM00190424.pdf

 and reference manual

http://www.st.com/content/ccc/resource/technical/document/reference_manual/c5/cf/ef/52/c0/f1/4b/fa/DM00124865.pdf/files/DM00124865.pdf/jcr:content/translations/en.DM00124865.pdf

. section (33 Serial audio interface (SAI)) for more details about SAI. 

Regards
misterstarshine
Associate III
Posted on September 16, 2016 at 12:23

Thanks for your reply.

To me it seems like the function BSP_AUDIO_OUT_Init which is used in many examples out there completely overrides the settings in the MX_SAI2_Init function that comes from STM32CubeMX. BSP_AUDIO_OUT_Init is required for the BSP_AUDIO_OUT_Play function to work. The function BSP_AUDIO_OUT_Play does not work with the MX_SAI2_Init function. It appears that the code generated from STM32CubeMX seems to conflict with the BSP_AUDIO library.

stm32cube-t
Senior III
Posted on September 20, 2016 at 13:14

Dear user,

STM32CubeMX takes care of the SAI peripheral initialization only. You are correct that the BSP code found in the examples is not based on STM32CubeMX generated code and performs its own initialization of the SAI peripheral.

Also you have two choices,

Either write your own BSP driver relying on MX generated code and taking ST BSP code as example.

Or to do the following: 1/ from within STM32CubeMX advanced project settings, choose the option to '' not generate'' the SAI initialization call. 2/ Manually import ST BSP code example in the project.

Best regards