Skip to content

Commit fe5ce82

Browse files
committed
[Nucleo-G071RB] Fix PB11/12 (ADC_IN15/16) analog read
Fixes #736 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 1fb5263 commit fe5ce82

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cores/arduino/stm32/analog.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,12 @@ uint16_t adc_read_value(PinName pin)
797797
#ifdef ADC_DATAALIGN_RIGHT
798798
AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; /* Right-alignment for converted data */
799799
#endif
800+
801+
#ifdef ADC_SCAN_SEQ_FIXED
802+
AdcHandle.Init.ScanConvMode = ADC_SCAN_SEQ_FIXED; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
803+
#else
800804
AdcHandle.Init.ScanConvMode = DISABLE; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
805+
#endif
801806
#ifdef ADC_EOC_SINGLE_CONV
802807
AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; /* EOC flag picked-up to indicate conversion end */
803808
#endif
@@ -886,7 +891,11 @@ uint16_t adc_read_value(PinName pin)
886891
#endif /* STM32L4xx || STM32WBxx */
887892
return 0;
888893
}
894+
#ifdef ADC_SCAN_SEQ_FIXED
895+
AdcChannelConf.Rank = ADC_RANK_CHANNEL_NUMBER; /* Enable the rank of the selected channels when not fully configurable */
896+
#else
889897
AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */
898+
#endif
890899
#if !defined(STM32L0xx)
891900
#if !defined(STM32G0xx)
892901
AdcChannelConf.SamplingTime = samplingTime; /* Sampling time value to be set for the selected channel */

0 commit comments

Comments
 (0)