cancel
Showing results for 
Search instead for 
Did you mean: 

Hello I am using STM32F746 discovery board and trying to transfer data in PCM format using I2S protocol provided

MYadw.2
Associate II

Hello

I am using STM32F746 discovery board and trying to transfer data in PCM format using I2S protocol provided.

I have configured for below mentioned settings

 hi2s2.Instance = SPI2;

 hi2s2.Init.Mode = I2S_MODE_MASTER_TX;

 hi2s2.Init.Standard = I2S_STANDARD_PCM_SHORT;

 hi2s2.Init.DataFormat = I2S_DATAFORMAT_16B;

 hi2s2.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;

 hi2s2.Init.AudioFreq = I2S_AUDIOFREQ_32K;

 hi2s2.Init.CPOL = I2S_CPOL_LOW;

 hi2s2.Init.ClockSource = I2S_CLOCK_PLL;

after successfully configuring when I am trying to transmit the data using

ret = HAL_I2S_Transmit(&hi2s2, &dum, 1, 100);

it is giving error in

// /* Wait until TXE flag is set */

 if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, Timeout) != HAL_OK)

 {

  /* Set the error code */

  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);

  hi2s->State = HAL_I2S_STATE_READY;

  __HAL_UNLOCK(hi2s);

  return HAL_ERROR;

 }

the TXE is not setting and hence the transfer of the data is not happening within the given timeout.

Please help me out in this its very urgent

3 REPLIES 3

Make sure the SPI/I2S module has a valid clock configured in RCC.

0693W00000UoCBLQA3.pngIf in doubts, read out and check/post RCC and SPI/I2S registers content.

JW

MYadw.2
Associate II

Hello,

As per the cubemx the clock configurations are done as follows

PeriphClkInitStruct.PLLI2S.PLLI2SN = 50;

  PeriphClkInitStruct.PLLI2S.PLLI2SP = RCC_PLLP_DIV2;

  PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;

  PeriphClkInitStruct.PLLI2S.PLLI2SQ = 2;

  PeriphClkInitStruct.PLLI2SDivQ = 1;

  PeriphClkInitStruct.I2sClockSelection = RCC_I2SCLKSOURCE_PLLI2S;

  

Still i could not able to transmit the data

Piranha
Chief II

SAI peripheral is the recommended choice for audio protocols instead of SPI/I2S peripheral.