CubeMX generates wrong I2S frequency on STM32F401C-Discovery
I have a clean slate CubeMX project on a STM32F401C-Discovery board. I have set up the onboard Cirrus audio DAC, and send a hard-coded test signal to it via DMA-driven I2S. I can hear the sound, but it is at wrong frequency.
The 2kHz test signal, and the i2s-3 is set to 48kHz samplerate, but depending on how I configure the PLL, I hear 122Hz, 180Hz or 244Hz audio. I have confirmed with a logic analyzer that the I2S protocol runs too slow. The only things I have changed from the CubeMX generated template project is:- enable i2c-1 (communication with the DAC, this works)
- enable i2s-3
- configure i2s-3 to have a cyclic DMA, 48kHz, 16bits on 32bit dataframe
In the source code, I only initialize the DAC and enable the DMA. No other changes to the generated source are done.
The three configurations I tried with:
PLLM=4 gives a I2S WS (frame clock) of 2.93kHz, and the 2kHz audio is at 122Hz:
With PLLM=6, I see a WS of 4.4kHz, and audio at 184Hz:

And with PLLM=8, WS is at 5.859kHz, and the audio at 244Hz:

CubeMX is version 4.21.0, F4-firmware package is version 1.16.0
Going through the STM32F401 reference manual and device registers hasn't yet given me a clue where CubeMX generates the bug.
Suggestions (and CubeMX bugfixes) much appreciated
kalle
#cubemx #i2s #frequency