cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 ADC 16bits resolution

New.Fish
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

9 REPLIES 9
S.Ma
Principal

True for a specific subset of newer STM32 parts.... check the STM32G4 or U5 first.

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"?

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.

Thanks.

There are some instructions about ADC oversampling in the user manual, that will be useful information.

AScha.3
Chief II

+ some have 16 b converters... i have here stm32H743 ->

0693W00000WHyQQQA1.png

If you feel a post has answered your question, please click "Accept as Solution".
Piranha
Chief II

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.

Hi Piranha,

It's nice to hear your experience, this is what exactly I want to know.

Two questions:

  1. You setup the A/D setting manually or by STMCube?
  2. 256X oversampling, that means sampling 256 times for each conversion, that will slow down the sample rate, how much is the final sample rate?

Regards

Sam

raptorhal2
Lead

(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;

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.