本帖最后由 e21 于 2015-5-14 18:31 编辑
一个旧项目不知改了什么地方,现I2S3无效(从模式接收)。I2S3配置不知缺了什么?以前I2S3曾是好用的。void I2S3_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
I2S_InitTypeDef I2S_InitStructure;
#ifdef I2S3_DMA
DMA_InitTypeDef DMA_InitStructure;
#endif
/* I2S3 GPIO Configuration
PA15 ------> I2S3_WS
PB3 ------> I2S3_CK
PB5 ------> I2S3_SD
*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); //SPI3时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE);
//I2S_Cmd(SPI3, DISABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); //关闭JTAG调试功能
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_5;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStruct);
SPI_I2S_DeInit(SPI3);
I2S_InitStructure.I2S_Mode = I2S_Mode_SlaveRx;
I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16bextended;
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;
I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_48k;
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
I2S_Init(SPI3, &I2S_InitStructure);
#ifdef I2S3_DMA
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);
//SPI_I2S_DMACmd(SPI3, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, DISABLE);
DMA_DeInit(DMA2_Channel1);
DMA_SetCurrDataCounter(DMA2_Channel1, 0);
DMA_ClearFlag(DMA2_FLAG_TC1 | DMA2_FLAG_TE1 | DMA2_FLAG_HT1 | DMA2_FLAG_GL1);//清除DMA1 channel5标志
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&SPI3->DR);
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)I2S3_Buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = I2S3_BUFFER_SIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel1, &DMA_InitStructure);
DMA_Cmd(DMA2_Channel1, ENABLE);
SPI_I2S_DMACmd(SPI3, SPI_I2S_DMAReq_Rx, ENABLE);
DMA_ITConfig(DMA2_Channel1, DMA_IT_TC, ENABLE);
#else
SPI_I2S_ITConfig(SPI3,SPI_I2S_IT_RXNE, ENABLE);
#endif
//等待WS跳变
delay1ms = 100;
while(I2S3_WS_HIGH){if(delay1ms == 0)break;};
while(!I2S3_WS_HIGH){if(delay1ms == 0)break;};
I2S_Cmd(SPI3, ENABLE);
}
|