从407 移植 到STM32F446, 两天了I2S一直没时钟出来。 求大神帮忙。
// 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");
}
} |
有做过的吗, 急