summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryn386 <wf.yn386@gmail.com>2022-10-22 16:19:58 +0900
committerDamien George <damien@micropython.org>2022-11-18 14:46:14 +1100
commitf6b5d1838b2c76cf4e5a18509c8fad91dbb01ed9 (patch)
tree4ebcc2c9b3917722ed91de1f639fbf221b8850b7
parent2154ee21635c85baf07e50ca1bfaf8c89cae192a (diff)
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.
-rw-r--r--ports/stm32/adc.c4
1 files 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);