| 
 
| 求stm32f4的i2s的初始化设置 我这么弄得
 void I2S_GPIO_Init(void)
 {
 GPIO_InitTypeDef GPIO_InitStructure;
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
 GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_SPI3);
 GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3);
 GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3);
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_12;
 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);
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
 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_NOPULL;
 GPIO_Init(GPIOA, &GPIO_InitStructure);
 GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_SPI3);
 }
 void Audio_I2S_Init(uint32_t AudioFreq)
 {
 I2S_InitTypeDef I2S_InitStructure;
 RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
 SPI_I2S_DeInit(SPI3);
 I2S_InitStructure.I2S_AudioFreq = AudioFreq;
 I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
 I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b;
 I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
 I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx;
 I2S_InitStructure.I2S_MCLKOutput =I2S_MCLKOutput_Enable;
 I2S_Init(SPI3,&I2S_InitStructure);
 I2S_Cmd(SPI3, ENABLE);
 }
 int main ()
 {
 
 I2S_GPIO_Init();
 Audio_I2S_Init(8000);
 while(1)
 {
 while((SPI3->SR&SPI_I2S_FLAG_TXE)==RESET);
 SPI3->DR =0;
 while((SPI3->SR&SPI_I2S_FLAG_TXE)==RESET);
 SPI3->DR =0;
 while((SPI3->SR&SPI_I2S_FLAG_TXE)==RESET);
 SPI3->DR =0xffff;
 while((SPI3->SR&SPI_I2S_FLAG_TXE)==RESET);
 SPI3->DR =0xffff;
 }
 }
 
 程序就卡在主函数里的第二个while那里,应该是初始化问题吧
 
 
 
 | 
 |