2016-09-15 07:19 AM
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?2016-09-15 08:00 AM
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 package, referred to this path: STM32Cube_FW_F7_V1.4.0\Projects\STM32756G_EVAL\Examples\SAI\SAI_AudioThis 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
and reference manual . section (33 Serial audio interface (SAI)) for more details about SAI. Regards2016-09-16 03:23 AM
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.2016-09-20 04:14 AM
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