cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 SAI/I2S slave issue?

admin239955
Associate II
Posted on March 09, 2016 at 13:53

Hi,

I am working on an application that streams audio from a WAV file on SD card. The core of the code is a hugely simplified version of the ''audio playback and record'' application from the Cube package. Audio output is via SAI1_B, running as a slave transmitter at 96kHz.

The SAI is set up for standard I2S with a 64-bit frame, two 32-bit slots. HAL data size is set to 16_BITEXTENDED (i.e. 16-bit data in a 32-bit slot).

In a nutshell, it doesn't quite work. The audio appears on the left output channel at half-speed while the right channel outputs noise. Examining the datastream clearly shows that 16-bit data is appearing in the slot for the left channel (with the remainder of the slot all zeroes, as it should be) but that the 32 bits of the right channel slot are either all high or all low.

So the device does not seem to be responding to the frame sync correctly; it is ignoring the second edge that marks the channel change. I have used the debugger to go through the config registers in fine detail and really cannot see anything incorrect.

I have read that there is a problem with I2S slave operation on some earlier STM32 devices. Is this still the case with the F7? The F7 errata refers to an issue with short frame sync pulses, but that does not seem to apply to standard I2S.

Has anyone else encountered this issue? Is there anything that I could be missing that might explain what I am observing?

Thanks for any insight.

Steve

2 REPLIES 2
Amel NASRI
ST Employee
Posted on March 14, 2016 at 15:45

Hi lenham.steve,

If you start from exactly the same example as the one in the Cube package, do you have any issue?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

admin239955
Associate II
Posted on March 15, 2016 at 15:19

Hi Mayla,

Thank you for your reply. I am pleased to say that I have found the cause of the problem.

Since the issue seemed to be associated with the frame sync, I first experimented with changing the sync function from ''Channel Identification'' to ''Start of Frame''. This resulted in audio on both channels, but it was very distorted. I eventually discovered that I had the bit clock edge set to the wrong polarity. Correcting this gave perfect audio on both channels, and I was also able to change the sync function back to Channel Identification.

Such a tiny mistake, yet so much lost time :(

BTW, to answer your question, it is not straightforward for me to run the ST examples because I am using Atollic Truestudio and have to build a project for them from scratch. Now that Atollic have released an unlimited, free version of Truestudio, I would strongly encourage ST to include it in the example project options. I initially tried SW4STM32 and found it unusable!

Kind regards,

Steve L.

 It is actually a bit difficult for me to try the examples