AnsweredAssumed Answered

Help with I2S in STM32F4 Discovery

Question asked by B3rsui on Mar 30, 2013
Latest reply on Apr 4, 2013 by waclawek.jan
Hello guys,

I have problems trying to interfacing the stm32f4 with the CS43L22 by the I2S protocol. I was able to set up and send the configurations words by I2C and see the handshaking between those with my oscilloscope, but I can't do the same with the I2S prot. So Im pretty sure that there is an error in my code. So please help me!

Here is my config code:

void I2S_LowLevel_Init(){

     GPIO_InitTypeDef     GPIO_InitStruct;
     I2S_InitTypeDef          I2S_InitStruct;

     I2S_StructInit(&I2S_InitStruct);                    /* Inicializo estructura */
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

     RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE);

     /* CODEC_I2S pins configuration: WS, SCK and SD pins -----------------------------
      * I2S3_SCK  = PC10
      * I2S3_SD   = PC12
      * I2S3_MCLK = PC7
     GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_12;
     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;
     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
     GPIO_Init(GPIOC, &GPIO_InitStruct);

     /* Connect pins to I2S peripheral  */
     GPIO_PinAFConfig(GPIOC, GPIO_Pin_7, GPIO_AF_SPI3);
     GPIO_PinAFConfig(GPIOC, GPIO_Pin_10, GPIO_AF_SPI3);
     GPIO_PinAFConfig(GPIOC, GPIO_Pin_12, GPIO_AF_SPI3);

     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;
     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOA, &GPIO_InitStruct);

    GPIO_PinAFConfig(GPIOA, GPIO_Pin_4, GPIO_AF_SPI3);//puerto, pines

//    RCC_I2SCLKConfig(RCC_I2S2CLKSource_PLLI2S);
//    RCC_GetFlagStatus(RCC_FLAG_PLLI2SRDY);

     I2S_InitTypeDef I2S_InitType;

     I2S_InitType.I2S_AudioFreq = I2S_AudioFreq_44k;
     I2S_InitType.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
     I2S_InitType.I2S_Mode = I2S_Mode_MasterTx;
     I2S_InitType.I2S_DataFormat = I2S_DataFormat_16b;
     I2S_InitType.I2S_Standard = I2S_Standard_Phillips;
     I2S_InitType.I2S_CPOL = I2S_CPOL_Low;

     I2S_Init(SPI3, &I2S_InitType);
     I2S_Cmd(SPI3, ENABLE);

I couldn't configure the I2S3_MCLK pin either. Sorry for my english and thanks for all!

Best regards,