2021-01-31 11:39 AM
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.
Solved! Go to Solution.
2021-02-03 03:41 AM
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.
2021-01-31 12:28 PM
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
2021-02-01 12:31 AM
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!
2021-02-03 03:41 AM
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.
2021-02-03 03:47 AM
Thanks for that!
I had come to the same conclusion, I was just hoping there was an easy way of doing it.
Andy.