summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/adc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ports/stm32/adc.c b/ports/stm32/adc.c
index c20e1bca4..f16159bef 100644
--- a/ports/stm32/adc.c
+++ b/ports/stm32/adc.c
@@ -304,7 +304,13 @@ STATIC void adc_config_channel(ADC_HandleTypeDef *adc_handle, uint32_t channel)
sConfig.OffsetRightShift = DISABLE;
sConfig.OffsetSignedSaturation = DISABLE;
#elif defined(STM32L4)
- sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
+ if (channel == ADC_CHANNEL_VREFINT
+ || channel == ADC_CHANNEL_TEMPSENSOR
+ || channel == ADC_CHANNEL_VBAT) {
+ sConfig.SamplingTime = ADC_SAMPLETIME_247CYCLES_5;
+ } else {
+ sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
+ }
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;