drivers: adc: stm32g0 fix sampling time due to errata sheet
According to the ES0418 about the ADC of the stm32G071
or other stm32g0x devices:
for sampling time set to 1.5 or 3.5 cycles,
the sampling in a single ADC conversion or in the first
conversion of a sequence takes one extra cycle.
Minimizing to 7.5 is fine.
Signed-off-by: Francois Ramu <francois.ramu@st.com>
diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c
index 794b2e6..d8b080a 100644
--- a/drivers/adc/adc_stm32.c
+++ b/drivers/adc/adc_stm32.c
@@ -837,6 +837,10 @@
LL_ADC_SetSamplingTimeCommonChannels(adc,
table_samp_time[acq_time_index]);
#elif defined(CONFIG_SOC_SERIES_STM32G0X)
+ /* Errata ES0418 and more: ADC sampling time might be one cycle longer */
+ if (acq_time_index < 2) {
+ acq_time_index = 2;
+ }
LL_ADC_SetSamplingTimeCommonChannels(adc, LL_ADC_SAMPLINGTIME_COMMON_1,
table_samp_time[acq_time_index]);
#else