2015-10-28 03:27 PM
Hi,
In my design I'm using an external 24.576 MHz oscilator as I2S clock source
Acoording to the reference manual, for 32 bit frames and MCLK output:F
S
= I2SxCLK / [(32*2)*((2*I2SDIV)+ODD)*4)]
ForFs = 96 KHz, this gives
I2SDIV = 0, ODD = 1.However, in the CubeMX configuration tab this shows an error:''With this I2S Clock (24.576 MHz), the divider value(0) is too low to obtain the desired audio frequency(96.0 KHz).The I2S Clock must be higher than (86.016 MHz).''I don't understand where this 86.016 MHz is coming from.Is there something happening between the external input pin and the I2S clock generator that I'm missing? Or is this a bug in CubeMX?2015-10-29 03:53 AM
> For
Fs = 96 KHz, this gives
I2SDIV = 0, ODD = 1. Minimum I2SDIV is 2, see SPI_I2SPR.I2SDIV description in RM0090 Rev.11 Ch.28.5.9. > I don't understand where this 86.016 MHz is coming from. From CubeMX :) The miminum input frequency is different (your homework to calculate), and I have no idea how could it be miscalculated to that value. JW2015-10-29 05:51 AM
Hi tim,
As Jan said the I2SDIV [7:0] = 0 or I2SDIV [7:0] = 1 are forbidden values.(86.016 MHz) is the value that should be in the I2S Clock to obtain the desired audio frequency (96.0 KHz).-Syrine-2015-10-29 08:35 AM
> (86.016 MHz) is the value that should be in the I2S Clock to obtain the desired audio frequency (96.0 KHz).
Certainly not; not with MCLK output set. The minimum frequency is forI2SDIV=2, ODD=0, I2SxCLK = Fs * [(32*2)*((2*I2SDIV)+ODD)*4)]
= 96k * (32 * 2) * 2 * 2 + 0) * 4 = 98.304MHz. Without MCLK, there *may* be one setting where 86.016MHz leads to 96kHz output, but it's not the lowest input frequency either. JW2015-10-29 09:38 AM
Right, I totally missed the forbidden values.. Derp.
Well that's too bad.. An external oscillator running at 98.304MHz is quite expensive.I wish it would be easier to achieve error-free sampling rates.Thanks for the insight!2015-10-29 10:18 AM
> Well that's too bad.. An external oscillator running at 98.304MHz is quite expensive.
Isn't this the reason why I2S has its own PLL? Some codecs have it too. > I wish it would be easier to achieve error-free sampling rates. Do you have some clocking requirement which prevents you to use the24.576
MHz oscillator (or, better, half of that) as the main clock source? JW2015-10-29 03:55 PM
> Do you have some clocking requirement which prevents you to use the
24.576
MHz oscillator (or, better, half of that) as the main clock source?Yeah I thought of that too, if I use a 12.288 MHz oscilator as main clock with m=8, I can use the I2SPLL to get the 98.304 MHz I2S clock (N=128, Q =2).I've noticed that the SAI-blocks are a bit more flexible in their clock generation than I2S, with SAI it seems I can even get Fs = 192 KHz with MCLK = 128 x Fs (that's what my ADC & DAC need at that samplerate, for others they take 256 x Fs).The main clock would then be 179,712 MHz with main PLL N=234, P=2.But, for accurate 44.1 KHz and their sibling sample rates, I would need a 11.2896 MHz oscilator. I can enable them seperately with GPIO's, but then I'd need to switch over to the internal 16 Mhz HSI during the changing of oscillators. So:-Disable SAI-Disable PLLSAI-Set clock mux to HSI-Disable Main PLL-Disable external oscillator 1 (12.288 MHz)-Enable external oscillator 2 (11.2896 MHz)-Setup Main PLL to almost 180 MHz-Re-enable Main PLL-Set clock mux to PLLCLK-Re-enable PLLSAI with N=128, R =4-Re-nable SAIDoes this seem at all feasible or in any way possible? When setting the clock mux to HSI in CubeMX, it says that HCLK must be at least 30 MHz. So why offer this possibility?The reason I'm contemplating this complex setup is because I would really like to use the ADC and DAC I've planned, without any samplerate error.Cheers,Tim2015-10-29 04:38 PM
Ah, no, actually I can just use the 11.2896 MHz oscillator on the I2S external clock input and switch the SAI clock mux whenever I need to have 44.1 kHz or divide it further.
I also see that MCLK = 256 x Fs always, but I can divide it by 2 in hardware externally to obtain MCLK = 128 x Fs for 192 kHz.2015-10-30 03:15 AM
In this case, I'd consider using a CODEC with built-in fractional-N PLL or other way of generating all the needed frequencies/signals, and use that as the I2S clock source.
JW2015-10-30 04:02 AM
Also, MCLK can be generated using a timer, if the AHB->APB frequency is adequate, and given the phase shift can be handled.
Also, the I2S - if you are in the 1Mpcs/yr cathegory, you might try to get a confirmation from ST for this. JW