cancel
Showing results for 
Search instead for 
Did you mean: 

Unstable working of I2S on STM32

cubefilm
Associate
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 below

test 0 :  3592

 

test 1 :  3592

 

test 2 :  3592

test 3 :     0

test 4 :  3592

test 5 : 32177

test 6 :  4095

test 7 : 32177

test 8 :    63

test 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
4 REPLIES 4
mike2001
Associate II
Posted on August 09, 2013 at 09:52

Did you read errata sheet? There is HUGE BUG in ALL STM32 micros. In slave mode WS (Frame sync) signal is ignored. You must enable I2S peripheral BEFORE any incoming transmission (stream). Why ST can't correct this!? 5 years and nothing changed }:

cubefilm
Associate
Posted on August 10, 2013 at 06:58

Thank you so much! 

andprice
Associate II
Posted on August 13, 2013 at 22:06

Does this bug also apply to the I2Sxext interfaces for full duplex mode?  I think you have to run those in slave mode even if the I2Sx interface is in master mode.

etudanilo
Associate
Posted on January 07, 2015 at 05:06

Hello Frank,

I am working on a project now. I have designed an interface to convert AES/EBU digital  and Analog audio inputs to I2S. I am working with a frequency of 192kHz. I want to test the designed systems with Nucleo STM32 Evaluation boards.

I am having some difficulties with the coding. Please , i would appreciate if you can help me

Best regards

Dan