2022-11-09 04:58 PM
STM32 MCU has 12 bits ADC resolution, but some MCU claim "up to 16-bit with hardware oversampling". When I setup ADC in STMCubeMX, no option for "hardware oversampling", how to achieve 16-bit ADC resolution?
Solved! Go to Solution.
2022-11-09 09:37 PM
If it's in the hardware, then it's probably described in the reference manual.
You shouldn't trust Cube anyway.
And my experience: as soon as you're really working (and not just "playing around") with the STM32, you need some deeper understanding, which means you should do lots of register reads and writes directly, and Cube and HAL functions mostly only serve as some setup, or a base for finding out what's going on.
2022-11-09 07:55 PM
True for a specific subset of newer STM32 parts.... check the STM32G4 or U5 first.
2022-11-09 08:03 PM
From the STM32Cube, I can find several STM32 family MCU have this feature, such as: STMG0, G4....
My question is how to setup "hardware oversampling"?
2022-11-09 09:37 PM
If it's in the hardware, then it's probably described in the reference manual.
You shouldn't trust Cube anyway.
And my experience: as soon as you're really working (and not just "playing around") with the STM32, you need some deeper understanding, which means you should do lots of register reads and writes directly, and Cube and HAL functions mostly only serve as some setup, or a base for finding out what's going on.
2022-11-09 10:06 PM
Thanks.
There are some instructions about ADC oversampling in the user manual, that will be useful information.
2022-11-10 12:02 AM
+ some have 16 b converters... i have here stm32H743 ->
2022-11-10 05:04 PM
Just for an information... There has been reports saying "it's just noise", but I can not agree. I'm capturing a good quality signal on L43x with it's 12-bit ADC in 256x oversampling mode and a 16-bit output. And, by analyzing the captured values, I can see that the noise is just a few LSB, which means the effective resolution is pretty close to 16-bit.
2022-11-10 05:15 PM
Hi Piranha,
It's nice to hear your experience, this is what exactly I want to know.
Two questions:
Regards
Sam
2022-11-10 06:48 PM
(Edited)
The configuration is done in the ADC handle initialization. Here is an L4 example:
/* Configuration of ADC Oversampling. Available for L4 Series
* Oversample Ratios are 2,4,8,16,32,64,128,256 */
AdcHandle.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_256;
/* Right shift sample sums are 0 to 8 */
AdcHandle.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4;
2022-11-14 07:23 PM
I'm not using HAL/Cube broken bloatware at all.
Of, course, oversampling slows down the whole conversion, but it still significantly depends on a sampling time:
Fadcclk / (Tsmpl + Tsar) / 256
80 MHz / (2,5 + 12,5) / 256 = 20833 Hz
80 MHz / (640,5 + 12,5) / 256 = 478 Hz
For my particular project even the slowest one is fine, because that device samples with an even lower frequency anyway.