cancel
Showing results for 
Search instead for 
Did you mean: 

SAI in SAI_I2S_STANDARD Mode...

Wood.Andy
Associate III

What happened to the equivalent of I2S_FLAG_CHSIDE as I don't seem to be able to find it.

Or do you just count the interrupts and assume it goes Left - Right - Left... forever?

Thanks

Andy.

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

For SAI peripheral channel "side" indication is not possible, because SAI supports up to 16 slots (channels). The next logical thing seems to be an indicator of slot index, but that would also be very problematic, because SAI has internal FIFO buffer. Therefore they implemented an intelligent overrun management. When the FIFO is full, it drops incoming data, but, when the FIFO is freed, it recovers at the same slot position on a new frame. Therefore slot alignment is always kept correct and counting slots is safe even under overrun condition.

Read the description of SAI FIFO overrun functionality in reference manual.

View solution in original post

4 REPLIES 4

What is I2S_FLAG_CHSIDE? Is it some "library" stuff?

> Or do you just count the interrupts and assume it goes Left - Right - Left... forever?

Well, I guess it's quite rare to use interrupts with I2S, but basically, yes.

JW

I2S_FLAG_CHSIDE tells you which channel you are currently in a transaction with - left or right.

Look in STM32 manuals in I2S sections for CHSIDE

32.7.3 Supported audio protocols

The three-line bus has to handle only audio data generally time-multiplexed on two

channels: the right channel and the left channel. However there is only one 16-bit register

for transmission or reception. So, it is up to the software to write into the data register the

appropriate value corresponding to each channel side, or to read the data from the data

register and to identify the corresponding channel by checking the CHSIDE bit in the

SPIx_SR register. Channel left is always sent first followed by the channel right (CHSIDE

has no meaning for the PCM protocol).

It means you don't have to count packets to know which one is current.

      if (SPI_I2S_GetFlagStatus(SPI2, I2S_FLAG_CHSIDE))

      

Having to count using SAI is a bit rubbish and a backward step!

And I use interrupts with I2S and it works very well!

Piranha
Chief II

For SAI peripheral channel "side" indication is not possible, because SAI supports up to 16 slots (channels). The next logical thing seems to be an indicator of slot index, but that would also be very problematic, because SAI has internal FIFO buffer. Therefore they implemented an intelligent overrun management. When the FIFO is full, it drops incoming data, but, when the FIFO is freed, it recovers at the same slot position on a new frame. Therefore slot alignment is always kept correct and counting slots is safe even under overrun condition.

Read the description of SAI FIFO overrun functionality in reference manual.

Wood.Andy
Associate III

Thanks for that!

I had come to the same conclusion, I was just hoping there was an easy way of doing it.

Andy.