cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446RE I2S can't output clock

khuan.81
Associate

hi all,

I wan to use PA4, PA5 and PA7 as I2S.

but can't output clk. follow is code for I2S setting:

// clock setting

  RCC_PLLI2SConfig(16, 334, 2, 7, 7);

  RCC_I2SCLKConfig(RCC_I2SBus_APB1, RCC_I2SCLKSource_PLLI2S);

  //RCC_I2SCLKConfig(RCC_I2SBus_APB2, RCC_I2SCLKSource_PLLI2S);

  RCC_PLLI2SCmd(ENABLE);

  while(RCC_GetFlagStatus(RCC_FLAG_PLLI2SRDY) == RESET);

u8 I2S1_GPIO_Init(void)

{

  u8 res;

  GPIO_InitTypeDef GPIO_InitStructure;

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;//

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//

  GPIO_Init(GPIOA, &GPIO_InitStructure);//

   

  GPIO_PinAFConfig(GPIOA,GPIO_PinSource4,GPIO_AF_SPI1); //

  GPIO_PinAFConfig(GPIOA,GPIO_PinSource5,GPIO_AF_SPI1); //

  GPIO_PinAFConfig(GPIOA,GPIO_PinSource7,GPIO_AF_SPI1); //

return 0;

}

void I2S1_Init(u16 I2S_Standard, u16 I2S_Mode, u16 I2S_Clock_Polarity, u16 I2S_DataFormat)

{

  I2S_InitTypeDef I2S_InitStructure;

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE); 

  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE); 

  I2S_InitStructure.I2S_Mode = I2S_Mode;

  I2S_InitStructure.I2S_Standard = I2S_Standard;

  I2S_InitStructure.I2S_DataFormat = I2S_DataFormat; 

  I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable; 

  I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_Default; 

  I2S_InitStructure.I2S_CPOL = I2S_Clock_Polarity; 

  I2S_Init(SPI1, &I2S_InitStructure); /

  SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, ENABLE); 

  I2S_Cmd(SPI1, ENABLE); 

}

...

void main(void)

{

  I2S1_GPIO_Init();

I2S1_Init(I2S_Standard_Phillips,I2S_Mode_MasterRx,I2S_CPOL_Low,I2S_DataFormat_16b);

  while (1)

  {

    asm("nop");

  }

}

6 REPLIES 6

Read out and check/post the content of relevant GPIO and SPI/I2S registers.

JW

khuan.81
Associate

I have check all the pin. and change the RCC setting. but all can't work. can you help me. or have some demo share to me.

Thanks

Kenny

As I've said, read out and check or post the content of relevant GPIO and SPI/I2S registers.

JW

As I've said, read out and check or post the content of relevant GPIO and SPI/I2S registers.

JW

[doubled post due to forum bug]

[doubled post due to forum bug]