Skip to main content
Son, Dong-Seong
Associate III
February 7, 2023
Question

About Audo codec example code with STM32H747I-DISCO

  • February 7, 2023
  • 3 replies
  • 2036 views

Hi

I have a STM32H747I-DISCO board

I want to test Audio codec ( WM8994ECS/R ) with SAI

I didnot find an example code for it.

Can I get an example code for Audio Codec with IOC file

This topic has been closed for replies.

3 replies

ST Technical Moderator
February 7, 2023

Hello @Son, Dong-Seong​,

You can get inspired from the SAI example available within STM32CubeH7 MCU package:

\STM32Cube_FW_H7_Vx.x.x\Projects\STM32H745I-DISCO\Examples\SAI\SAI_AudioPlayback\

This example runs on STM32H747xx/STM32H745xx devices, and you can follow the readme file to make the program work.

You can refer to the reference manual RM0399 section 54 Serial audio interface (SAI) and the user manual UM2488 section 6.7 Audio.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Son, Dong-Seong
Associate III
February 8, 2023

Thank you for your response.

I am setting from IOC file by referring to SAI_AudioPlayback code.

​The following is the configuration of the ioc file

0693W00000YAG0wQAH.jpg​The following is the code that performed [generate code] from the ioc file.

 hsai_BlockA4.Instance = SAI4_Block_A;

 hsai_BlockA4.Init.Protocol = SAI_FREE_PROTOCOL;

 hsai_BlockA4.Init.AudioMode = SAI_MODESLAVE_RX;

 hsai_BlockA4.Init.DataSize = SAI_DATASIZE_16;

 hsai_BlockA4.Init.FirstBit = SAI_FIRSTBIT_LSB;

 hsai_BlockA4.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;

 hsai_BlockA4.Init.Synchro = SAI_ASYNCHRONOUS;

 hsai_BlockA4.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;

 hsai_BlockA4.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_HF;

 hsai_BlockA4.Init.SynchroExt = SAI_SYNCEXT_DISABLE;

 hsai_BlockA4.Init.MonoStereoMode = SAI_STEREOMODE;

 hsai_BlockA4.Init.CompandingMode = SAI_NOCOMPANDING;

 hsai_BlockA4.Init.TriState = SAI_OUTPUT_RELEASED;

 hsai_BlockA4.Init.PdmInit.Activation = DISABLE;

 hsai_BlockA4.Init.PdmInit.MicPairsNbr = 1;

 hsai_BlockA4.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;

 hsai_BlockA4.FrameInit.FrameLength = 32;

 hsai_BlockA4.FrameInit.ActiveFrameLength = 1;

 hsai_BlockA4.FrameInit.FSDefinition = SAI_FS_STARTFRAME;

 hsai_BlockA4.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH;

 hsai_BlockA4.FrameInit.FSOffset = SAI_FS_FIRSTBIT;

 hsai_BlockA4.SlotInit.FirstBitOffset = 0;

 hsai_BlockA4.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE;

 hsai_BlockA4.SlotInit.SlotNumber = 2;

 hsai_BlockA4.SlotInit.SlotActive = 0x00000002;

 if (HAL_SAI_Init(&hsai_BlockA4) != HAL_OK)

 {

  Error_Handler();

 }

​I don't know where [hsai_BlockA4.Init.PdmInit.] in the code above is in the IOC file.

That part is different from the part in the SAI_AudioPlayback code, but I don't know where to modify it in the ioc file.

Please let me know where to fix.

Son, Dong-Seong
Associate III
February 8, 2023

Thank you for your response.

I am setting from IOC file by referring to SAI_AudioPlayback code.

​The following is the configuration of the ioc file

0693W00000YAG0wQAH.jpg​The following is the code that performed [generate code] from the ioc file.

  hsai_BlockA4.Instance = SAI4_Block_A;

  hsai_BlockA4.Init.Protocol = SAI_FREE_PROTOCOL;

  hsai_BlockA4.Init.AudioMode = SAI_MODESLAVE_RX;

  hsai_BlockA4.Init.DataSize = SAI_DATASIZE_16;

 hsai_BlockA4.Init.FirstBit = SAI_FIRSTBIT_LSB;

  hsai_BlockA4.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;

  hsai_BlockA4.Init.Synchro = SAI_ASYNCHRONOUS;

  hsai_BlockA4.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;

  hsai_BlockA4.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_HF;

  hsai_BlockA4.Init.SynchroExt = SAI_SYNCEXT_DISABLE;

  hsai_BlockA4.Init.MonoStereoMode = SAI_STEREOMODE;

  hsai_BlockA4.Init.CompandingMode = SAI_NOCOMPANDING;

  hsai_BlockA4.Init.TriState = SAI_OUTPUT_RELEASED;

  hsai_BlockA4.Init.PdmInit.Activation = DISABLE;

  hsai_BlockA4.Init.PdmInit.MicPairsNbr = 1;

  hsai_BlockA4.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;

  hsai_BlockA4.FrameInit.FrameLength = 32;

  hsai_BlockA4.FrameInit.ActiveFrameLength = 1;

  hsai_BlockA4.FrameInit.FSDefinition = SAI_FS_STARTFRAME;

  hsai_BlockA4.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH;

  hsai_BlockA4.FrameInit.FSOffset = SAI_FS_FIRSTBIT;

  hsai_BlockA4.SlotInit.FirstBitOffset = 0;

  hsai_BlockA4.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE;

  hsai_BlockA4.SlotInit.SlotNumber = 2;

  hsai_BlockA4.SlotInit.SlotActive = 0x00000002;

  if (HAL_SAI_Init(&hsai_BlockA4) != HAL_OK)

  {

   Error_Handler();

  }

​I don't know where [hsai_BlockA4.Init.PdmInit.] in the code above is in the IOC file.

That part is different from the part in the SAI_AudioPlayback code, but I don't know where to modify it in the ioc file.

Please let me know where to fix.