2023-07-07 01:02 PM
Could someone point me to some documentation about how to control the oversampling for ADC1 and ADC2 for the STM32MP157C? Using OpenSTLinux 4.1.0, buildroot. I looked around but couldn't find anything.
Thanks!
Solved! Go to Solution.
2023-07-10 04:01 AM - edited 2023-07-10 04:03 AM
Hello @Macdog ,
To enable the oversampling you have to modify the register ADC_CFGR2. The description of this register is visible in the Reference manual (RM0436 rev 6) chapter 29.6.5 ADC configuration register 2 (ADC_CFGR2).
The bits related to Oversampling are
Bits 25:16 OSVR[9:0]: Oversampling ratio
By default it is set to 0, but you can modify this value to go up to 1024x. Usually an oversampling of x16 is already enough to reduce the noise.
---
U-Boot and Linux
Are you working under U-Boot or Linux?
If you are using the ADC in Linux, as visible in the "Documentation/devicetree/bindings/iio/adc/adc.yaml" you can configure the oversampling ratio directly from the DTS by using the property:
oversampling-ratio
M4 only
You also have an example for M4 only in the STM32CubeMP1_Package in the example "ADC_OverSampler". In this example for STM32MP157C-EV1 board, the oversampling ratio is configured to x1024. You can read the readme to have more information regarding this example:
https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_Package_release_note_-_v1.6.0
You can download the STM32CubeMP1_Package on the wiki : https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-EV1/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Install_STM32CubeMP1_package
More general information
Finally if you want more additional information, but more generic one, you can read the AN2834 that provides information to have accurate measure in ADC: https://www.st.com/resource/en/application_note/CD00211314-.pdf
Hope it helps,
Best Regards,
Kevin
2023-07-10 04:01 AM - edited 2023-07-10 04:03 AM
Hello @Macdog ,
To enable the oversampling you have to modify the register ADC_CFGR2. The description of this register is visible in the Reference manual (RM0436 rev 6) chapter 29.6.5 ADC configuration register 2 (ADC_CFGR2).
The bits related to Oversampling are
Bits 25:16 OSVR[9:0]: Oversampling ratio
By default it is set to 0, but you can modify this value to go up to 1024x. Usually an oversampling of x16 is already enough to reduce the noise.
---
U-Boot and Linux
Are you working under U-Boot or Linux?
If you are using the ADC in Linux, as visible in the "Documentation/devicetree/bindings/iio/adc/adc.yaml" you can configure the oversampling ratio directly from the DTS by using the property:
oversampling-ratio
M4 only
You also have an example for M4 only in the STM32CubeMP1_Package in the example "ADC_OverSampler". In this example for STM32MP157C-EV1 board, the oversampling ratio is configured to x1024. You can read the readme to have more information regarding this example:
https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_Package_release_note_-_v1.6.0
You can download the STM32CubeMP1_Package on the wiki : https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-EV1/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Install_STM32CubeMP1_package
More general information
Finally if you want more additional information, but more generic one, you can read the AN2834 that provides information to have accurate measure in ADC: https://www.st.com/resource/en/application_note/CD00211314-.pdf
Hope it helps,
Best Regards,
Kevin