AnsweredAssumed Answered

Problem with configuration I2S interface

Question asked by krok.krzysztof on Aug 13, 2012
Latest reply on Aug 15, 2012 by krok.krzysztof
Hi everybody!

I used external codec ADAU1961 for collect data from two microphones.
I used I2S3 simplex mode for receiving data from codec to STM32F4.
I configured lines of peripheral I2S3 for transmition (WS - Word Select, CK - Serial Clock, SD - Serial Data).
I connected to the codec external master clock MCLK=12.288MHz.
I configured codec for sending sound in parameters: fs=48kHz, 2 channels, format data: 16-bit.
I2S is configured as slave only for receiving data and codec is configured as master only for sending data.

I try to store data in buffer and send it to SD Card.
I always receive noise instead of proper probes of sound through I2S3.

I have a questions:

1. Need I connect master clock MCLK=12.288MHz also to pin I2S_CKIN mapped on PC9 in STM32F4.
2. How I have to configure pin I2S_CKIN? I configured it as follow:

   GPIO_InitTypeDef GPIO_InitStructure;


   GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_SPI3);

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
   GPIO_Init(GPIOC, &GPIO_InitStructure);

3. How can I properly configure I2S3 for receiving data. I filled I2S_InitTypeDef structure as follow:

   I2S_InitTypeDef I2S_InitStructure;

   I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_48k;
   I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
   I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;
   I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
   I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b;
   I2S_InitStructure.I2S_Mode = I2S_Mode_SlaveRx;
   I2S_Init(I2Sx, &I2S_InitStructure);

   I2S_Cmd(I2Sx, ENABLE);

I use polling mode for receiving probes:

while (SPI_I2S_GetFlagStatus(SPI3, SPI_FLAG_TXE) == RESET)  {}
buffer[i] = SPI_I2S_ReceiveData(SPI3);

Could anybody know what I'm doing wrong?
Mayby I wrong configure codec ADAU1961?

I will be very happy for any suggestions.

Best regards!