Skip to content

stm32/sai: make NODIV independent of MCKDIV#4589

Merged
lulf merged 3 commits intoembassy-rs:mainfrom
tomaz-suller:feat-independent-nodiv
Aug 26, 2025
Merged

stm32/sai: make NODIV independent of MCKDIV#4589
lulf merged 3 commits intoembassy-rs:mainfrom
tomaz-suller:feat-independent-nodiv

Conversation

@tomaz-suller
Copy link
Copy Markdown
Contributor

@tomaz-suller tomaz-suller commented Aug 26, 2025

These values should clearly be made independent, at least in the WB55 microcontroller (and so I suspect in all the others) since NODIV implies no divider between the master clock and the bit clock, but it does NOT imply no divider between the SAI clock and the master clock. Quoting from the WB55 reference manual (RM0434 Rev 14, p. 1219):

Clock generator programming when NODIV = 1

When MCKDIV is different from 0, the frequency of the bit clock (SCK_x) is given in the
formula below:
$F_{SCK\_x} = F_{MCLK\_x} = \frac{F_{sai\_x\_ker\_ck}}{MCKDIV}$

Tests I have performed with the WB55 show you can use NODIV = 1 with MCKDIV != disabled and still get valid configurations and correct clock frequencies.
I'm not entirely sure about integrating this change though since CubeMX follows the same behaviour as Embassy currently (i.e. NODIV == MCKDIV disabled).

@lulf lulf enabled auto-merge August 26, 2025 09:19
auto-merge was automatically disabled August 26, 2025 09:21

Head branch was pushed to by a user without write access

@lulf lulf enabled auto-merge August 26, 2025 09:30
auto-merge was automatically disabled August 26, 2025 09:43

Head branch was pushed to by a user without write access

@tomaz-suller
Copy link
Copy Markdown
Contributor Author

@lulf I had to merge the changelog and the auto-merge got disabled again

@lulf lulf added this pull request to the merge queue Aug 26, 2025
Merged via the queue into embassy-rs:main with commit b6a81d8 Aug 26, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants