Skip to main content
hchoi.1
Associate
September 21, 2022
Question

STM32L4 ADC oversampling setup

  • September 21, 2022
  • 4 replies
  • 5786 views

0693W00000SvsRqQAJ.pngI want to use the adc 15bit resolution.

I don't understand why right shift and oversampling ratio are at the same time.

1. what is difference

12bit + 4bit right shift + oversampling ratio 128x

and

12bit + oversampling ratio 8x?

2. What are the functions and roles?

Please give me a detailed answer that is easy to understand

This topic has been closed for replies.

4 replies

ST Technical Moderator
September 21, 2022

Hello @hchoi.1​ and welcome to the Community :)

You find details in AN4629 Application note "ADC hardware oversampling for microcontrollers of the STM32 L0 and L4 series". This application note explained the basics of the oversampling technique used to improve the SNR performances (and thus the effective resolution) of ADCs integrated in microcontrollers of the STM32 L0 and L4 series.

According to this training STM32L4-ADC, the oversampler can accommodate from 2 to 256 times samples and right shift from one to eight binary digits.

You can also get inspired from the working example from STM32L4 MCU package (using with LL driver):

\STM32Cube_FW_L4_V1.17.2\Projects\NUCLEO-L476RG\Examples_LL\ADC\ADC_Oversampling\

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
hchoi.1
hchoi.1Author
Associate
September 22, 2022

What's the reason for doing the right shift?

waclawek.jan
Super User
September 22, 2022

If you oversample by 2^N (N=7 in case of oversampling by 128) the 12-bit ADC result is added 2^N times, resulting in 12+N-bit number (in case of N=7 it's 19 bits). The ADC data register is only 16-bit, so if the mcu wouldn't right-shift before moving the result from the 20-bit internal accumulator into ADC data register, the uppermost bits (19-16=3 in case of N=7) would get lost.

JW

hchoi.1
hchoi.1Author
Associate
September 23, 2022

thanks for your answer JW

i understood your comment​.

so then, what is difference 12bit + 4bit right shift + oversampling ratio 128x and 12bit + oversampling ratio 8x?

Both are equal to 15 bits ADC.

noise? anti-aliasing? or what?

waclawek.jan
Super User
September 23, 2022

Your measurement will take 128x longer but you'll have cca 11x less noise.

[EDIT] see Piranha's post below - indeed, I compared it to single conversion which wouldn't return 15 bits, so it's an incorrect comparison[/EDIT] 

https://en.wikipedia.org/wiki/Oversampling#Resolution

JW

Piranha
Principal III
September 28, 2022

An oversampling of 128x compared to 8x will take 128/8=16 times longer and will give sqrt(16)=4 times less noise.