From 94467110a95d44371881e931fd9c0f703fe7ee67 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 3 Feb 2020 15:11:44 +0100 Subject: [PATCH] analogRead: don't set ADC common register when ADC doesn't support it. STM32F103ZE: ADC3 doesn't support common settings. __LL_ADC_COMMON_INSTANCE(ADC3) returns 0 --- libraries/SrcWrapper/src/stm32/analog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/SrcWrapper/src/stm32/analog.cpp b/libraries/SrcWrapper/src/stm32/analog.cpp index 13eeac5147..84ce86ba28 100644 --- a/libraries/SrcWrapper/src/stm32/analog.cpp +++ b/libraries/SrcWrapper/src/stm32/analog.cpp @@ -1006,8 +1006,9 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution) return 0; } - LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(AdcHandle.Instance), LL_ADC_PATH_INTERNAL_NONE); - + if (__LL_ADC_COMMON_INSTANCE(AdcHandle.Instance) != 0U) { + LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(AdcHandle.Instance), LL_ADC_PATH_INTERNAL_NONE); + } return uhADCxConvertedValue; } #endif /* HAL_ADC_MODULE_ENABLED && !HAL_ADC_MODULE_ONLY*/