STM32 ADC 16bits resolution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 4: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.
- Labels:
-
ADC
-
STM32CubeMX
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 9: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 7:55 PM
True for a specific subset of newer STM32 parts.... check the STM32G4 or U5 first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 8: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"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 9: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 10:06 PM
Thanks.
There are some instructions about ADC oversampling in the user manual, that will be useful information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-10 12:02 AM
+ some have 16 b converters... i have here stm32H743 ->
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-10 5: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-10 5:15 PM
Hi Piranha,
It's nice to hear your experience, this is what exactly I want to know.
Two questions:
- You setup the A/D setting manually or by STMCube?
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-10 6: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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 7: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.
