Skip to main content
TDJ
Senior III
October 30, 2023
Question

What is SAI "Error between selected"? (CubeMX bug?)

  • October 30, 2023
  • 10 replies
  • 5063 views

Today I spent some time to fine-tune SAI clock to get standard 22.05kHz sample output rate.
However, I do not understand why CubeMX states that "Error between selected" is 0.22%.

What is "Error between selected"? Why this error is zero when selected frequency actually differs from the desired value by 0.05kHz? Am I missing something?

SAI3.png

SAI2.png

SAI4.png

This topic has been closed for replies.

10 replies

Pierre_Paris
ST Employee
October 31, 2023

Hello @TDJ,

Thank you for bringing this issue to our attention.

I confirm the issue and I reported internally.

Internal ticket number: 165344 (This is an internal tracking number and is not accessible or usable by customers).

Thank you for your contribution in STCommunity ! :)

Pierre

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.
AScha.3
Super User
October 31, 2023

@TDJ  , i can confirm: the % deviation is the cause of many a good laugh . 

Whoever programmed this , has a big problem with with 3rd class mathematics. just laugh briefly and hope,

the calculated frequency is right. (which seems to be ok in my tests).

what is really bad in the SAI frequency setting is the divider , in my opinion.

almost impossible, to find a clock/divider setting, that makes 44100, 48000, 96000, 192000 Hz possible.

so i set it to slave + transmitter and the dac (ES9038) generates the sampling frequency at any value (32bit frequency value).

If you feel a post has answered your question, please click on " Best Answer ".
TDJ
TDJAuthor
Senior III
October 31, 2023

@AScha.3 I agree. Luckily, by fine-tuning PLL one can get really close and 0.001 HZ difference should no be audible even to musicians blessed with perfect pitch. That remains to be tested yet. Another approach I tried was using PLL 441x multiplier but I could not find settings within allowable frequency limits. So the current approach, that is, PLL3 clocked by 16MHz MSIS CRS-SYNCed with very stable LSE 32.768 kHz, may be the best one.

AScha.3
Super User
October 31, 2023

i (until now) never used the fractional setting in pll, because the jitter on the STM cpu is anyway not great, a cheap ESP8266 is better. And the fractional part...what could it do? switch the pll divider a step an back, in sigma/delta way. i cannot imagine, this will make a useful clock...did you check the jitter?

and for other dac, SAI in master transmit, i used:

AScha3_0-1698754334014.png

with HSE 8M crystal , gives in Cube:

AScha3_1-1698754424335.png

0,086% says my calculator. :)  (44100 / 44062 = 1,0008624) too difficult for STM software.

thats ok, so far.

If you feel a post has answered your question, please click on " Best Answer ".
LCE
Principal II
October 31, 2023

@AScha.3 ES9038, wow, never heard of that DAC and that company. Thanks for mentioning that device, so that I found another audio converter alternative (mostly ADCs, for industrial purposes, but audio range).

AScha.3
Super User
October 31, 2023

:)

the ES9038 is at the top group of audio dacs of the world...

AScha3_2-1698755059333.png

 

 

and they have also ADC; mouser  has ES9826Q ; 

If you feel a post has answered your question, please click on " Best Answer ".
LCE
Principal II
October 31, 2023

Concerning STM32 PLL and jitter:

I have used a few Nucleos (G4, F767, H723, with the ST-Link MCO as clock source) and a H735-DK and the PLL as source for SAI / I2S. 
I have not seen any bad impact on signal quality, with TX-SPDIF and with 115dB SNR audio ADCs (sampling rate up to 200 kHz).

I think the jitter would have impact on non-oversampling ADCs.