From f6b5d1838b2c76cf4e5a18509c8fad91dbb01ed9 Mon Sep 17 00:00:00 2001 From: yn386 Date: Sat, 22 Oct 2022 16:19:58 +0900 Subject: [PATCH] stm32/adc: Fix ADCAll.read_core_temp() on L4 MCUs. TS_CAL1 and TS_CAL2 of STM32L4 are at VDDA=3.0V, so the reference correction factor should be updated before reading tempsensor. --- ports/stm32/adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/stm32/adc.c b/ports/stm32/adc.c index 5aa7ce426..2df6b7abf 100644 --- a/ports/stm32/adc.c +++ b/ports/stm32/adc.c @@ -860,9 +860,9 @@ float adc_read_core_temp_float(ADC_HandleTypeDef *adcHandle) { return 0; } #else - #if defined(STM32L1) + #if defined(STM32L1) || defined(STM32L4) // Update the reference correction factor before reading tempsensor - // because TS_CAL1 and TS_CAL2 of STM32L1 are at VDDA=3.0V + // because TS_CAL1 and TS_CAL2 of STM32L1/L4 are at VDDA=3.0V adc_read_core_vref(adcHandle); #endif int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR);