cancel
Showing results for 
Search instead for 
Did you mean: 

In STM32F031K6, project file imported has 239.5 cycle set in ADC sampling time. Im getting 200count samples in a sec.(i.e.,each data once in 5ms which is 200Hz). I need to increase the sampling frequency to 200kHz(5uS in time). Pls sugges parameter to set

AK H
Associate II
 
7 REPLIES 7

System clock frequency, ADC clock source and prescaler, number of channels in a sequence, samping time set for each channel, method how sequences are started and data are read out and - all have impact on the number of conversions of one channel per second.

Read the ADC chapter in RM and proceed accordingly.

JW

AK H
Associate II

Thanks, for the sampling frequency change does that required to regenerate the code in MX cube or can be edited in main.c file previously generated and used in STM32cubeIDE.

Thanks, for the sampling frequency change does that required to regenerate the code in MX cube or can be edited in main.c file previously generated and used in STM32cubeIDE.

The compiler builds the code you present it.

You can independently edit the code, rearrange it, change the clock settings and relationships.

You can also use the TIM to trigger the ADC at intervals that differ from the sampling rate, and on some parts you can interleave the ADC to pipeline the sample-hold-conversion.

The STM32F031K6 has one ADC, but can support 1Msps

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AScha.3
Chief III

it seems the AI wants to talk us to death...

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

If the prescaler is 4, how do I confirm the value of f_adc as 12MHz, sampling cycle set for 239.5 cycle in initialization. If so is it sampling at every 19.95uS. I knew Tconv = (Sampling time + cycles) / (ADC clk). But I am huge difference, getting data every 5ms and sampling time set for 19.95uS. pls correct which part Im missing.

> getting data every 5ms

Most likely, the code you are using for "getting data" has an execution time of around 5ms, regardless of how long it takes the ADC to sample and convert one sample.

What we are trying to tell you is, that for anything faster than that, you need to read the manual and write your own code, with understanding of what operation takes how much time to execute. It's not enough to click in CubeMX and call a bunch of Cube functions.

You can start with toggling a pin at various points of your code and observing it using oscilloscope/logic analyser.

JW