2022-10-17 06:21 AM
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
2022-10-17 06:54 AM
Make sure the SPI/I2S module has a valid clock configured in RCC.
If in doubts, read out and check/post RCC and SPI/I2S registers content.
JW
2022-10-18 01:49 AM
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
2022-10-19 10:26 AM
SAI peripheral is the recommended choice for audio protocols instead of SPI/I2S peripheral.