2025-05-12 5:06 AM
Hi
I'm trying to sample a sine wave between 400 and 500 kHz with the Nucleo H723ZG. I'm using the 16 bit adc 1 with following configuration:
I'm trying to calculate the correct frequency of the signal. The calculated frequency fluctuates between +-500Hz, which is not accurate enough.
The code to calculate the frequency has been tested with pre-generated values with a given frequency and works fine with an accuracy of +- 1Hz.
I already checked the reference voltage VREF, which is fine, and removed L1 (as described in https://community.st.com/t5/stm32-mcus-products/fluctuations-in-adc-value-of-stm32h743-mcu/m-p/331501#M79889).
There seems to be a problem with the sampling / sampling rate.
Any solutions will be highly appreciated .
Thank you
Solved! Go to Solution.
2025-05-12 6:02 AM
Using 8 MHz from ST_Link has no sense, since ST-Link is running on it's own HCI in default config. You need to reprogram ST-Link to run on 25 MHz crystal clock , than divide by 3 - so strange 8.33 MHz output. My understanding that ST use 25 to comply with Ethernet 50 MHz requirements.
It's not very convenient to re-map all frequencies, I usually set PLL to 950 MHz for my H743/753, but it's the easiest way to have clean primary clock on nucleo-H7.
2025-05-12 5:39 AM
500 Hz / 2 MHz ~= 10^-3, this is about what I'd expect from RC oscillator. Seems HCI is primary clock, try to change HSE in by-pass and feed 8.33 MHz out of ST-Link. You have to reconfigure ST_Link as well
2025-05-12 5:48 AM
How are you calculating the frequency?
Using an FFT with a peak estimation is going to give the highest accuracy.
Share some data with actual frequency and calculated frequency.
2025-05-12 5:50 AM
Hi @MasterT
Thanks for your answer. I allready use the HSE clock, which is from the ST-Link (8 MHz).
Is there maybe something else wrong with the clock configuration?
2025-05-12 6:01 AM
@TDKthanks for your answer. I'm using an FFT and the goertzel algorithm to estimate the frequency. I did some frequency calculation on the microcontroller (1000 values):
The input frequency was generated with a signal generator (457 kHz) and checked with a spectrum analyzer. The accuracy of the generator is +- 2Hz.
As mentioned before: I checked the frequency calculation with pre-generated values and it works fine, also on the microcontroller.
2025-05-12 6:02 AM
Using 8 MHz from ST_Link has no sense, since ST-Link is running on it's own HCI in default config. You need to reprogram ST-Link to run on 25 MHz crystal clock , than divide by 3 - so strange 8.33 MHz output. My understanding that ST use 25 to comply with Ethernet 50 MHz requirements.
It's not very convenient to re-map all frequencies, I usually set PLL to 950 MHz for my H743/753, but it's the easiest way to have clean primary clock on nucleo-H7.
2025-05-12 6:44 AM
@MasterTthank you very much for your help. I changed the ST-Link clock to the 25 MHz crystal oscillator and divided it by 5 (5 MHz). After changing the clock configuration in CubeMX, it worked perfectly fine!
2025-05-12 6:56 AM
BS, there is no option divide by 5.
2025-05-12 7:29 AM
Yes there is the option, I use the ST-Link upgrade version 3.16.8. Maybe it also depends on the nucleo board, I use the H723ZG...
2025-05-12 7:31 AM
Ooooops, mea culpa.
Thanks for reply, will update my software