I2S2 已经作为输出用了,现在需要I2S3作为输入连接ADC, 设置好后发现读出的数据都是0, 怀疑其没有工作,后来将I2S3设为输出并增加上中断,发现进不了中断,I2S2是工作正常的,I2S3就多了remap,有没有遇到类似问题的?多谢! void I2S_In_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; I2S_InitTypeDef I2S_InitStructure; /* Enable GPIOA, GPIOC and AFIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); /* Enable I2S3 APB1 clock */ //RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); /* I2S3 MCLK,SD, SCLK pins configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /* I2S2 WS LRCK pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* remap */ GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE); /* Enable I2S2 APB1 clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); /* Deinitialize SPI3 peripheral */ SPI_I2S_DeInit(SPI3); /* I2S2 peripheral configuration */ I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx; I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips; I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b; I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable; I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_44k; I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low; I2S_Init(SPI3, &I2S_InitStructure); /* Enable the SPI3/I2S peripheral */ I2S_Cmd(SPI3, ENABLE); } void I2S_In_DMA_Config(void) { /* I2S3 DMA2 Channel Config */ /* Peripheral control structures */ DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_DMA2_Channel2; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)PCMBuffer1; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SPI3_DR_Address; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 1; 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_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; NVIC_DMA2_Channel2.NVIC_IRQChannel = DMA2_Channel2_IRQn; NVIC_DMA2_Channel2.NVIC_IRQChannelPreemptionPriority = 0x01; NVIC_DMA2_Channel2.NVIC_IRQChannelSubPriority = 0x00; NVIC_DMA2_Channel2.NVIC_IRQChannelCmd = ENABLE; /* Initialize the DMA2 Channel2 to its default values */ DMA_DeInit(DMA2_Channel2); /* Configure the DMA parameters */ DMA_Init(DMA2_Channel2, (DMA_InitTypeDef *) &DMA_InitStructure); NVIC_Init((NVIC_InitTypeDef *)&NVIC_DMA2_Channel2); DMA_ClearFlag(DMA2_FLAG_GL2); DMA_ITConfig(DMA2_Channel2, DMA_IT_TC, ENABLE); /* Enable DMA2 Channel2 */ DMA_Cmd(DMA2_Channel2, ENABLE); /* Enable I2S DMA request for TX */ SPI_I2S_DMACmd(SPI3, SPI_I2S_DMAReq_Tx, ENABLE); } |
【MCU实战经验】基于STM32F103C8T6的hart总线调试器设计
求教STM32F103进入STOP模式后用外部中断唤醒的问题
基于STM32F103RCT6的无源蜂鸣器音乐播放(生日快乐歌)
STM32F103c8t6有没有DAC 功能?
STM32F103x中文数据手册
新手求教,为何在我电脑上找不到STM32F1Xx.h文件
金龙107例程汇总(STM32F107)
万利STM32F107VC 原理图
STM32F103 ADC多通道检测必须要DMA吗?
【官方例程】STM32F107以太网官方例程
RE:STM32F105RC I2S3 的设置问题,请帮助