2024-09-26 07:48 PM
Hello everyone, I'm using the STM32CubeIDE , then I would like to ask about the ADC configuration for the STM32F429 board. Currently, I want to distinguish a sine wave input ranging from 10kHz to 3MHz, the ADC parameters are set as follows:
(1) APB 1 peripheral: 36 MHz
(2) Clocks Prescaler: Divided by 2
(3) Sampling Time: 3 Cycles
Additionally, the TIM is set to 72 MHz, with PSC: 0 and ARR: 11. How should I configure it? Thank you, everyone!
2024-09-26 09:20 PM
What aspects of the sine wave are you trying to distinguish?
Is it just to see if there is or isn’t a sine-wave at the input?
Or do you want to measure both frequency and amplitude in order to detect changes in either of them?
Nyquist sampling theory tells us that you need to sample at least twice the frequency of the incoming waveform. So for 3MHz you would need 6MSamples/s. I don’t think a standard stm32 ADC can do that. So you might need to choose between having additional hardware or relaxing the measurement requirements.
2024-09-26 09:30 PM
Hello, thank you for your reply.
I want to read the sine wave generated by my circuit, use the ADC to capture 4095 data points, and then use FFT to obtain the frequency and amplitude.
I would also like to ask if using multiple ADC channels can measure higher frequency ranges?
And how should I configure TIM and ADC, and which is more important?
I’ve searched various articles online but still don’t understand. Thank you!
2024-09-27 06:53 AM
I doubt you're going to successfully read a 3 MHz sine wave. The ADC sampling rate is limited.
Regardless, the procedure for reading frequency is:
2024-09-27 07:42 AM
>>> STM32F429
How is that : (1) APB 1 peripheral: 36 MHz.
Data sheet tels F429 runs at 180 MHz. Have you mistyped F103?
2024-09-27 08:27 PM
HI, thank you for your response. Based on my calculations, the highest sampling rate I can achieve is 2.4 MSPS (36M/15). According to Nyquist's theorem, if I need to sample 1024 points for a 10kHz sine wave, the required sampling frequency would be 10k * 2 * 1024 = 20.48 MHz. If I reduce the FFT requirement to 100 points, then the required sampling frequency would be 10k * 2 * 100 = 2 MHz. Does this mean that I cannot meet my requirements using the STM32F429?
2024-09-27 08:31 PM
HI, thank you for your response.I made a mistake in the values; the APB2 is 72 MHz, and as shown in the figure, the maximum achievable rate is 36 MHz.
2024-09-27 08:37 PM
Yes, you cannot measure a 3 MHz sine wave with a sample rate of less than 2x that frequency, or 6 MSPS. That is beyond the capabilities of a single ADC. You can do dual or triple interleaved mode, but the programming and post-processing is considerably more complicated. You will have considerable noise on the circuit as well at those speeds. Might be better ways to accomplish what you want. Probably aren't going to be able to take an FFT continuously at those rates, but you could do snapshots.
STM32™'s ADC modes and their applications
2024-09-27 09:24 PM
Thank you for your response. I would like to ask if my calculation is correct. If I only need to measure a 1 MHz sine wave, but my FFT requires 100 points, is it still impossible to use the STM32F429 for this measurement?