cancel
Showing results for 
Search instead for 
Did you mean: 

Can't setup I2S master clock output on STM32F303CBT6 in IOC editor

yusenpai
Associate II

Ảnh màn hình 2023-11-02 lúc 10.56.40.png

Ảnh màn hình 2023-11-02 lúc 10.56.21.png

Hi, I'm trying to set up the I2S of STM32F303CBT6. Everything was fine until I checked the box "Master Clock Output", it said "With this I2S Clock (8.0 MHz), the divider value (0) is too low to obtain the desired Audio Frequency(44.0 KHz). The I2S Clock must be higher than (39.424 MHz)", although I had turned on the HSE with PLL, which is 72MHz of system clock. Am I missing something or it's a problem with STM32CubeIDE itself?

Edit: Added IOC file.

1 ACCEPTED SOLUTION

Accepted Solutions

now i tried with a real F303 , to see what its doing real:

first set it to I2S , 48khz (wished) , no i2s_mco:

AScha3_2-1699628900977.png

and 47,873KHz coming out.  :) :)

(72MHz / 1504 = 47,87234 kHz --- we need @Piranha to find the mathe , how to get "50.0kHz real" here )

AScha3_1-1699628825091.png

next: switch on mco (in debug->periph.registers MCKOE called here) -> FS now 5,9842kHz !

so DIV 1/8 switched in. 

i couldnt find this behavior in manual... the secrets of STM , maybe.

ed.  Jan found it ... :)

so its no basic error in Cube, the clock is divided by 8 , as soon as mco on.

simply said: unusable at > 8kHz and standard audio FS, with audio dacs, that need a master-clk. 

with i2s-mco ON , max FS is 70..kHz. 

next possible with direct register setting and mco:

70,314 kHzwith I2SPR at 0x202 mco then 18,00 MHz

56,252 with I2SPR at 0x302

46,8766kHz with I2SPR at 0x203

40,18kHz with I2SPR at 0x303 

(real setting here: 72MHz /7 (=mco)/256 (= FS) = 40,1786 kHz)

so just this IS possible.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

9 REPLIES 9
Peter BENSCH
ST Employee

Welcome @yusenpai, to the community!

Please post the IOC so that people can try to understand.

Regards
/Peter

 

In order 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.

This is probably CubeMX bug, but maybe it's just incorrect wording.

In 'F3, I2S clock is either System clock or external clock from the I2S_CKIN pin, as set by RCC_CFGR.I2SSRC; the default being the former.

So, assuming Cube "knows" this, it may try to calculate a divisor from 72MHz which would yield the requested 44.1kHz * 256 = 11.2896MHz for MCO, and fails; however, it incorrectly displays the I2S clock frequency.

The 44.1kHz audio frequency is a relatively strange one, and you have to start with chosing a primary clock (crystal) which can be successfully divided into this frequency.

JW

Hi,
For some reason, I can't upload my IOC here. In the IOC file, first I set up the HSE PLL clock with 16MHz crystal and 72MHz system clock. Then I set the I2S2 to full-duplex master mode, communication standard is I2S Philip, Data and Frame format is 16 bits data on 16 bits frame, 44KHz audio freq. When turning on Master clock output or changing to 24 bits data on 32-bit frame, I get the error message saying 8MHz is too low.

1.png

2.png

Hi.
I also think that's a bug. Because I set up the system clock to 72MHz first, then set up the I2S later.

Thank you for your response.

Peter BENSCH
ST Employee

The file check during upload should have just been changed so that you should be able to insert IOC files. If you still have a problem with this, you can add the additional suffix .txt as a workaround.

In order 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.

i just tried same setting, 72M core, I2S on 44k , then activate mck out -> get same error:

AScha3_0-1699603591747.png

--- but where this 8M clock coming ??

If you feel a post has answered your question, please click "Accept as Solution".

to put in i2s external clock, >48 pin case is needed...

AScha3_0-1699605366190.png

PC9 is not here, in 48pin case. so we cannot use/switch to i2s_ckin.

but internal clock should not be 8M ! 

 

clock tree from ds :

AScha3_1-1699605597559.png

so I2S clk should come from sysclk (72M) , not be 8M (...HSI RC is 8M ??)

AScha3_2-1699606223303.png

 

who is wrong here ?  Cube or datasheet ?

 

If you feel a post has answered your question, please click "Accept as Solution".

now i tried with a real F303 , to see what its doing real:

first set it to I2S , 48khz (wished) , no i2s_mco:

AScha3_2-1699628900977.png

and 47,873KHz coming out.  :) :)

(72MHz / 1504 = 47,87234 kHz --- we need @Piranha to find the mathe , how to get "50.0kHz real" here )

AScha3_1-1699628825091.png

next: switch on mco (in debug->periph.registers MCKOE called here) -> FS now 5,9842kHz !

so DIV 1/8 switched in. 

i couldnt find this behavior in manual... the secrets of STM , maybe.

ed.  Jan found it ... :)

so its no basic error in Cube, the clock is divided by 8 , as soon as mco on.

simply said: unusable at > 8kHz and standard audio FS, with audio dacs, that need a master-clk. 

with i2s-mco ON , max FS is 70..kHz. 

next possible with direct register setting and mco:

70,314 kHzwith I2SPR at 0x202 mco then 18,00 MHz

56,252 with I2SPR at 0x302

46,8766kHz with I2SPR at 0x203

40,18kHz with I2SPR at 0x303 

(real setting here: 72MHz /7 (=mco)/256 (= FS) = 40,1786 kHz)

so just this IS possible.

If you feel a post has answered your question, please click "Accept as Solution".

next: switch on mco (in debug->periph.registers MCKOE called here) -> FS now 5,9842kHz !

so DIV 1/8 switched in.

i couldnt find this behavior in manual.

waclawekjan_1-1699688036761.png

As I've said above, if your goal is to have a particular audio frequency, you *start* with selecting an appropriate crystal, rather than trying to fit a integer-multiple-of-1MHz onto the desired audio frequency.

That CubeMX can't calculate is another thing. Just don't use it.

JW