Question
Unstable working of I2S on STM32
Posted on August 08, 2013 at 21:17
I faced a critical problem of i2s of STM32.
I'm developing a simple system for i2s level meter.MCU - STM32F103RCT6 with external X-tal(12MHz), 72MHz of running clock Inpit Audio - 48KHz, 16bits, stereo i2s digital audio (MCU pin : WS, SD, SCK used)Using the ST library,First, I set RCC like this,SystemInit (); // set system clock - 72MHz...RCC_APB1PeriphClockCmd( RCC_APB1Periph_I2C1 | RCC_APB1Periph_SPI2, ENABLE ); // I2S...then, I set I2Ss port,NVIC_InitTypeDef NVIC_InitStructure; /* SPI2 IRQ channel configuration */NVIC_InitStructure.NVIC_IRQChannel = SPI2_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;NVIC_Init(&NVIC_InitStructure); SPI_I2S_DeInit(SPI2); /* I2S peripheral configuration */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;/* I2S2 configuration */I2S_InitStructure.I2S_Mode = I2S_Mode_SlaveRx;I2S_Init(SPI2, &I2S_InitStructure);/* Enable the I2S2 */I2S_Cmd(SPI2, ENABLE);/* Enable the I2S2 RxNE interrupt */SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, ENABLE);After that, I read i2s register, when i2s audio of simple tone signal was connected,the maximum value was changed intermittently.10 results of test are belowtest 0 : 3592test 1 : 3592
test 2 : 3592test 3 : 0test 4 : 3592test 5 : 32177test 6 : 4095test 7 : 32177test 8 : 63test 9 : 3592( expected value of I2S is 3592)I guess this problem is about init i2s port or clock,so I did almost change options.(changed Dataformat, Mode, CPOL, AudioFreq...)but it was not effective.Would you help me if you have an experience of i2s?Thanks for all,Frank #slave #stm32 #i2s