cancel
Showing results for 
Search instead for 
Did you mean: 

SAI Clock Generator in Slave mode

digigram
Associate
Posted on June 03, 2016 at 11:17

Hello,

In order to use both SAI_A and SAI_B, both in slave mode, on a STM32L4, I am wondering if the SAI_CK clock is used ? 

An external device is supposed to provide the BCLK and the FS clock (in my case), and the reference manual says that ''When the audio block is defined as slave, the clock generator is OFF.'' (p.1328). This makes me think that I don't need to generate any further clock for the SAI. But under CubeMX, I can change SAI1 and SAI2's clocks. I can even use an external SAIx clock with an input. 

So do I need to provide any clock for the two SAI (which are both in slave mode) with the BCLK and the FS clock ? If not, why CubeMX gives me the possibility to change SAI1 and SAI2 clock ?

Thanks,

Florian
9 REPLIES 9
Walid FTITI_O
Senior II
Posted on June 03, 2016 at 12:22

Hi ch..florian,

I report this internally to our CubeMx team for check.

-Hannibal-

digigram
Associate
Posted on June 07, 2016 at 09:09

Hello Hannibal,

Thank you for reporting this. Do you have any news about my questions ?

Florian

Jeanne Joly
Senior III
Posted on January 11, 2018 at 11:41

Hello ch..florian,

If you still have some doubts on how SAI works on STM32L4, I invite you to have a look to the following doc (

http://www.st.com/content/ccc/resource/training/technical/product_training/0c/16/3b/b4/76/8a/47/51/STM32L4_Peripheral_SAI.pdf/files/STM32L4_Peripheral_SAI.pdf/jcr:content/translations/en.STM32L4_Peripheral_SAI.pdf

).

In few words, The SAI is composed of two independent sub-blocks (A and B). Each sub-block can be configured in receive or transmit, master or slave, with its own protocol.

If the SAI synchronization is not used, each sub-block is independent. Some examples : 

  • SAI_A in I2S Philips Master, SAI-B in SPDIF.
  • SAI_A in TDM slave, SAI_B in AC97.

In slave mode, the SAI is receiving the timing signals from an external device : 

  • the bit clock (SCK), the frame synchonization (FS).
  • the serial data line (SD) can be input or output.

And in salve mode, the MCLK (master clock) is not used.

Sorry for the late answer...

BR

Jeanne

Posted on January 18, 2018 at 21:29

But this does not answer the original queson: why does CubeMX allow to set and change SAI clocks when they are not used in slave mode?

JW

Posted on January 19, 2018 at 10:01

hi

Waclawek.Jan

,

For your information, I am using CUbeMX4.23 (the latest).

When SAI1_A and SAI1_B are in slave mode, you can't change, in SAI1 configuration, the audio frequency.

Here is an example where SAI1_A is in master mode and SAI1_B in slave : (SAI1_A audio clock can be changed, not the SAI1_B) :

0690X00000609QgQAI.png

I assume that you already seen that.

I guess that your point is more regarding the clock configuration view.

If you configure SAI1_A and SAI1_B in slave mode and RCC as SAI1 Extern Clock (that is close to your use case), you can do as follow :

0690X00000609M7QAI.png

fill the SAI1 extern clock and it will calculate automatically the SAI1 clk.

Moreover, you can change the SAI1 clk itself and it will change the PLLSRC that is normal.

See the scheme below that is taken from the doc I advised you in my last post :

0690X00000609QqQAI.png

I hope it is clearer.

If not, please be more precise (send an ioc, a picture of the symptom you see) in order to help you.

BR. Jeanne

Posted on January 19, 2018 at 10:50

I am not the original poster, and I don't use Cube/CubeMX.

So, while the question was formulated in terms of CubeMX (why can SAIx clock be set in CubeMX if both SAIx channels are slaves), the implication of the question was: If both channels of one SAI channel are slaves, does it need input clock on its sai_*_ker_ck terminals?

0690X00000609R5QAI.png

JW

Posted on January 19, 2018 at 11:46

Regarding your question, yes, you need an input clock for the SAI clock generator whatever the mode (slave, master) of the SAI channels.

BR. Jeanne

Posted on January 20, 2018 at 12:09

Wow. This is strange, as:

0690X00000609RKQAY.png

What's the purpose of the input clock in slave mode, then? And, more importantly, what should be its frequency (perhaps in relationship to input FS/SCK frequency)?

Can you please point out, where in RM is this dealt with?

Thanks,

JW

Posted on June 23, 2018 at 16:56

Did we get a proper answer on this?

we need an RCC clock to drive SAIx even if both SAIx_Block_A & SAIx_Block_B are set to slave and use CK and FS ??

how do we calculate the appropriate RCC clock for this ? my external DSP will change CK FS depending on mode.