Skip to content

Commit 373f7c5

Browse files
committed
Fixed ADC read value
Fix stm32duino#168 Last STM32L4xx HAL Drivers update change ADC init (using LL). Some ADC_ChannelConfTypeDef fields were missing. Mainly SingleDiff. Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 0e046b5 commit 373f7c5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: cores/arduino/stm32/analog.c

+5
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@ uint16_t adc_read_value(PinName pin)
606606
AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */
607607
#ifndef STM32L0xx
608608
AdcChannelConf.SamplingTime = SAMPLINGTIME; /* Sampling time value to be set for the selected channel */
609+
#endif
610+
#if defined (STM32F3xx) || defined (STM32L4xx)
611+
AdcChannelConf.SingleDiff = ADC_SINGLE_ENDED; /* Single-ended input channel */
612+
AdcChannelConf.OffsetNumber = ADC_OFFSET_NONE; /* No offset subtraction */
613+
AdcChannelConf.Offset = 0; /* Parameter discarded because offset correction is disabled */
609614
#endif
610615
/*##-2- Configure ADC regular channel ######################################*/
611616
if (HAL_ADC_ConfigChannel(&AdcHandle, &AdcChannelConf) != HAL_OK)

0 commit comments

Comments
 (0)