2026-01-20 7:38 AM - edited 2026-01-20 7:40 AM
Doing the set up in MX
I have four ADC channels on APB2 with PCLK2 at 84 MHz sampling 4 microphones.
The recommended audio sampling rate stretch from 44.1 kHz up to 96 kHz, so initially I'm happy anywhere in that range for now.
I have set the clock pre-scaler to divide PCLK2 / 4 so the ADC clock is at 21 MHz
I have 12 bit resolution which takes 15 ADC cycles but then in the "rank" section of the parameter settings there is a pull down for sampling time for each channel. I'm guessing that the value I pass in the "rank" section is what I would use to get the final sampling rate.
e.g. if I chose 84 cycles for each channel then I would have a sample rate of 250 kHz per channel giving a sample rate for all conversions of 62.5 kHz?
Or do I add the sample time to the resolution time e.g. 84+15 giving a sample rate of ~212 kHz per channel?
Solved! Go to Solution.
2026-01-20 7:50 AM - edited 2026-01-20 11:51 AM
The total time to convert a channel is sampling time + conversion time.
I believe 12-bit resolution requires 12 cycles to convert, not 15. So your total time would be 84 + 12 cycles per sample.
2026-01-20 7:50 AM - edited 2026-01-20 11:51 AM
The total time to convert a channel is sampling time + conversion time.
I believe 12-bit resolution requires 12 cycles to convert, not 15. So your total time would be 84 + 12 cycles per sample.
2026-01-20 7:54 AM
Thanks, MX is saying "15 ADC clock cycles" for 12 bits which is an annoying number for sure.
2026-01-20 8:09 AM - edited 2026-01-20 8:09 AM
If you want a specific sampling time, it's easier to have them triggered from a timer rather than in continuous mode. Set up the conversions to complete at least as fast as the timer triggers.
2026-01-20 11:02 AM - edited 2026-01-20 11:05 AM
See rm...ADC :
So ADC needs 12 ckls for conversion, + time for sampling ;
min. 12+3 = 15, max. 12+480 = 492 clks.
At your chosen 21 MHz you get : 0.71 us ... 23.4 us conversion time.
So just select the sampling time that comes close to the conversion time you want.
(or adjust the adc clock in allowed range to get other conversion times.)
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.