Skip to content

Commit 572ab24

Browse files
FRASTMcfriedt
authored andcommitted
drivers: adc: stm32 disable the ADC before setting the Resolution
On those STM32 series, setting of this feature is conditioned to the ADC state: it is allowed to write the Data resolution (RES bits) in the ADC_CFGR1 register only when ADC is disabled (ADEN=0). Signed-off-by: Francois Ramu <[email protected]>
1 parent affae9b commit 572ab24

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/adc/adc_stm32.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,18 @@ static int start_read(const struct device *dev,
409409
return err;
410410
}
411411

412-
#if defined(CONFIG_SOC_SERIES_STM32G0X)
412+
#if defined(CONFIG_SOC_SERIES_STM32G0X) || \
413+
defined(CONFIG_SOC_SERIES_STM32G4X) || \
414+
defined(CONFIG_SOC_SERIES_STM32H7X) || \
415+
defined(CONFIG_SOC_SERIES_STM32L0X) || \
416+
defined(CONFIG_SOC_SERIES_STM32L4X) || \
417+
defined(CONFIG_SOC_SERIES_STM32L5X) || \
418+
defined(CONFIG_SOC_SERIES_STM32WBX) || \
419+
defined(CONFIG_SOC_SERIES_STM32WLX)
413420
/*
414421
* Errata: Writing ADC_CFGR1 register while ADEN bit is set
415422
* resets RES[1:0] bitfield. We need to disable and enable adc.
423+
* On all those stm32 devices it is allowed to write these bits only when ADEN = 0.
416424
*/
417425
if (LL_ADC_IsEnabled(adc) == 1UL) {
418426
LL_ADC_Disable(adc);

0 commit comments

Comments
 (0)