STM32L4, voltage breakdown on high-impedance ADC input after MX_ADCx_Init
Hello everyone,
I measure a voltage on a STM32L496 using the internal ADC and found the following issue:
Setup:
The voltage is scaled down via a high-impedance voltage divider (2 x 470kOhm). To avoid distortion by sampling, the voltage divider has a 100nF capacitor. Thus, the capacitive load while sampling is low and the breakdown is 1/20000 → i.e. way lower than the ADC’s resolution. So I do not have to care about source impedance limitations as described in the datasheet (Maximum ADC RAIN).
Other data:
- VREF=VDDA=3.3V (stable)
- Voltage range of ADC input signal: 0 - 3V (never >3.3V)
Effect:
I experience a large voltage breakdown when I configure the ADC, via CubeMX generated function MX_ADC3_Init (same happens when I use ADC1). I found, that within MX_ADC3_Init the channel gets configured and the ADC sequencer register ADC_SQR1 is set (I only sample that one channel with the high-impedance voltage divider). As soon as ADC_SQR1 is set, the voltage breaks down, from anything >2.5V to approx. 2.5V. When I enable the ADC (ADC_CR.ADEN=1) the breakdown disappears, and there is no more breakdown during sampling (due to high 100nF capacitor). I experience again a breakdown when calling HAL_ADC_DeInit() → ADC is disabled before ADC_SQR1 register is cleared.
Explanation:
Explanation for the above effect is that with ADC_SQR1 being set the external signal is connected to the ADC. Since the ADC is off (ADC_CR.ADEN=0) its state is undefined causing the clipping on the external signal. As soon as the ADC is on everything is defined and ok.
Question:
Is this behavior intended, do you want to fix it, offer a second init-function?
I understand that CubeL4-codes idea is to configure and then to measure. But in case of high impedance sources I find the behavior critical. Anybody experienced the same issue?
