Skip to main content
olivier.scalbert
Associate III
August 15, 2021
Question

SAI4 on STM32H735G-DK

  • August 15, 2021
  • 2 replies
  • 982 views

Hello,

I would like to use the MEMS included on this board, to learn SAI, which I never used before.

I have used STM32MxCube to setup a project.

In SAI4, SAI A, I select "Pulse Density Modulation using Microphones pairs (1-2) and CK2 as clock.

STMCube generates:

static void MX_SAI4_Init(void)
{
 
 /* USER CODE BEGIN SAI4_Init 0 */
 
 /* USER CODE END SAI4_Init 0 */
 
 /* USER CODE BEGIN SAI4_Init 1 */
 
 /* USER CODE END SAI4_Init 1 */
 hsai_BlockA4.Instance = SAI4_Block_A;
 hsai_BlockA4.Init.Protocol = SAI_FREE_PROTOCOL;
 hsai_BlockA4.Init.AudioMode = SAI_MODEMASTER_RX;
 hsai_BlockA4.Init.DataSize = SAI_DATASIZE_8;
 hsai_BlockA4.Init.FirstBit = SAI_FIRSTBIT_MSB;
 hsai_BlockA4.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;
 hsai_BlockA4.Init.Synchro = SAI_ASYNCHRONOUS;
 hsai_BlockA4.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
 hsai_BlockA4.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE;
 hsai_BlockA4.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
 hsai_BlockA4.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_192K;
 hsai_BlockA4.Init.MonoStereoMode = SAI_STEREOMODE;
 hsai_BlockA4.Init.CompandingMode = SAI_NOCOMPANDING;
 hsai_BlockA4.Init.PdmInit.Activation = ENABLE;
 hsai_BlockA4.Init.PdmInit.MicPairsNbr = 1;
 hsai_BlockA4.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK2_ENABLE;
 hsai_BlockA4.FrameInit.FrameLength = 8;
 hsai_BlockA4.FrameInit.ActiveFrameLength = 1;
 hsai_BlockA4.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
 hsai_BlockA4.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;
 hsai_BlockA4.FrameInit.FSOffset = SAI_FS_FIRSTBIT;
 hsai_BlockA4.SlotInit.FirstBitOffset = 0;
 hsai_BlockA4.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE;
 hsai_BlockA4.SlotInit.SlotNumber = 1;
 hsai_BlockA4.SlotInit.SlotActive = 0x00000000;
 if (HAL_SAI_Init(&hsai_BlockA4) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN SAI4_Init 2 */
 
 /* USER CODE END SAI4_Init 2 */
 
}

There is nothing concerning SAI pinout in MX_GPIO_Init.

In "Clock configuration", SAI4A is set to 96MHz.

When I compile and run the project, I do not get any clock on the MEM (checked with a scope).

Other FreeRTOS tasks are running well (blinking led and USART3 logger).

Any ideas to help me ?

Olivier

    This topic has been closed for replies.

    2 replies

    olivier.scalbert
    Associate III
    August 15, 2021

    I think the problem comes from the lack of GPIO initialization.

    SAI4_CK2 should come from PE5, but I do not know how to set the pin correctly (alternate).

    Explorer
    October 10, 2023

    Did you solve this problem? i'm in the same situation and there's no much information out there