2018-10-21 01:45 AM
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");
}
}
2018-10-21 03:13 PM
Read out and check/post the content of relevant GPIO and SPI/I2S registers.
JW
2018-10-23 07:17 PM
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
2018-10-24 12:37 AM
As I've said, read out and check or post the content of relevant GPIO and SPI/I2S registers.
JW
2018-10-24 12:37 AM
As I've said, read out and check or post the content of relevant GPIO and SPI/I2S registers.
JW
2018-10-24 12:37 AM
[doubled post due to forum bug]
2018-10-24 12:37 AM
[doubled post due to forum bug]