AnsweredAssumed Answered

I2S code generated by STM32CubeMX for STM32F746 - no MCKO

Question asked by carp.florin on Dec 12, 2015
Latest reply on Dec 30, 2015 by Phan.Le_Son
Hello,

I'm using STM32CubeMX to generate a project for STM32F746VGT6.

Everything works fine except I2S3, there is no clock output on MCKO pin (PC7) and the call of HAL_I2S_Transmit(...) generates a timeout error.

The I2S3-related code generated by STM32CubeMX is:


void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s)
{
  GPIO_InitTypeDef GPIO_InitStruct;
  if(hi2s->Instance==SPI3)
  {
  /* USER CODE BEGIN SPI3_MspInit 0 */


  /* USER CODE END SPI3_MspInit 0 */
    /* Peripheral clock enable */
    __SPI3_CLK_ENABLE();
  
    /**I2S3 GPIO Configuration    
    PC7     ------> I2S3_MCK
    PA15     ------> I2S3_WS
    PC10     ------> I2S3_CK
    PC12     ------> I2S3_SD 
    */
    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_12;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);


    GPIO_InitStruct.Pin = GPIO_PIN_15;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


  /* USER CODE BEGIN SPI3_MspInit 1 */


  /* USER CODE END SPI3_MspInit 1 */
  }



void MX_I2S3_Init(void)
{
  hi2s3.Instance = SPI3;
  hi2s3.Init.Mode = I2S_MODE_MASTER_TX;
  hi2s3.Init.Standard = I2S_STANDARD_PHILIPS;
  hi2s3.Init.DataFormat = I2S_DATAFORMAT_16B;
  hi2s3.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE;
  hi2s3.Init.AudioFreq = I2S_AUDIOFREQ_8K;
  hi2s3.Init.CPOL = I2S_CPOL_LOW;
  HAL_I2S_Init(&hi2s3);
}


After calling these initialization routines in the main function, the MCKO on PC7 pin is not present (checked with an oscilloscope).
In the main loop I call HAL_I2S_Transmit(&hi2s3, DummySamples, 5, 250) - this is generating a timeout error.

Any clues ?

Thank you.

Outcomes