cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 H7 - I2S Clock Timing Problems (runs at 1.027 Mhz for some reason) - See PulseView

AnkhInnovationsLLC
Associate III

Hello,

Still trying to get I2S working on the H7...

Opened up PulseView to check the clock between another connected device...

Much to my surprise, the STM32 is actually outputting 1.027 Mhz average clock pulses instead of the ESP32's 1.024 Mhz. 

Checked the Clock in STM MX, shows 0% error and an input clock of 2.048 Mhz which is divisible. Tried also 20.48 Mhz with no change. There appears to be no divider settings. Any reason for this wrong output clock?

Screenshot 2023-10-30 at 12.29.16 PM.png

 

Screenshot 2023-10-30 at 12.29.37 PM.png


There are many "Expected 16 bit word, received 17 bit" etc, with varying bits because of the wrong clock. Expected is 16 bits.

 

Screenshot 2023-10-30 at 12.39.21 PM.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

You're using the HSE bypass as clock, which is clocked from the HSI on the ST-Link chip. Yes, it's 8 MHz nominal, but not accurate to what a crystal would be. ±0.3% is well within the guaranteed accuracy range.

TDK_0-1698707228097.png

Despite what the user manual says, you can change this from the default HSI output to HSE output at 8.333MHz if you open the st-link in update mode and choose that option. You would then need to update your clock tree based on this new value.

TDK_1-1698707254389.png

 

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

View solution in original post

10 REPLIES 10

What board are you using?

Be aware that the ST-LINK/V3 doesn't output a pure 8 MHz normally, typically around 8.333 MHz based on it's 25 MHz clock, and DIV3 on the MCO pin feeding the target MCU

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

Also be aware that ±0.3% is well within the tolerance of the HSI. HSE will need to be used to be more accurate.

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

Hi @Tesla DeLorean,

Using the Nucleo H723ZG... According to the PDF I found here, the HSE looks to be 8Mhz. 

Here's the clock config with the HSI. It looks like its off even more now, at 1.029 Mhz pulses.

Screenshot 2023-10-30 at 3.48.45 PM.png

TDK
Guru

You're using the HSE bypass as clock, which is clocked from the HSI on the ST-Link chip. Yes, it's 8 MHz nominal, but not accurate to what a crystal would be. ±0.3% is well within the guaranteed accuracy range.

TDK_0-1698707228097.png

Despite what the user manual says, you can change this from the default HSI output to HSE output at 8.333MHz if you open the st-link in update mode and choose that option. You would then need to update your clock tree based on this new value.

TDK_1-1698707254389.png

 

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

Okay, I'll try to change it to 8.33 the 8.33 option. Do you know the decimal places on this "8.33" or is it 8.33333333.

Edit: The only problem is there isn't a PLL combination I can come up with to output an accurate 2.048 signal now for the SAI bus (PDM mic) bus... 

It's 25/3 MHz.

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

I2S, SPI and I2C have a clock signal, on which the data is sampled, and therefore those are synchronous interfaces. And for such interfaces a specific frequency doesn't matter. For I2S the SD is sampled on the rising SCK edge. That means the SD and WS must be changing at the falling SCK edge. In your second picture the ESP32 signal is correct, but for the STM32 signal either the SD or WS is changing on the rising SCK edge, which is wrong.

 

P.S. Full information about the STLINK-V3 provided MCO output:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/how-to-change-the-stlink-v3e-mco-hse-frequency/td-p/218882

Thanks everyone!

@TDK 

@Tesla DeLorean 

@Piranha 

Screenshot 2023-10-30 at 5.55.23 PM.png

 

Screenshot 2023-10-30 at 5.59.41 PM.png

LCE
Lead III

I don't like these 8.333 MHz... but these are much better than the HSI, which is unusable for audio >= 16 bit resolution.

BUT, there are the FRACN registers for each PLL for fine tuning, which get you close enough to the frequencies you need. (Even better, these can be modified on the fly.)

Anyway, I2S is not that complicated to set up, so for full control and to know what's going on, better use direct register settings.