Skip to content

Commit 856da01

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 856da01

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cores/arduino/stm32/analog.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,11 @@ 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+
#ifdef ADC_SCAN_SEQ_FIXED
801+
AdcHandle.Init.ScanConvMode = ADC_SCAN_SEQ_FIXED; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
802+
#else
800803
AdcHandle.Init.ScanConvMode = DISABLE; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
804+
#endif
801805
#ifdef ADC_EOC_SINGLE_CONV
802806
AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; /* EOC flag picked-up to indicate conversion end */
803807
#endif
@@ -886,7 +890,11 @@ uint16_t adc_read_value(PinName pin)
886890
#endif /* STM32L4xx || STM32WBxx */
887891
return 0;
888892
}
893+
#ifdef ADC_SCAN_SEQ_FIXED
894+
AdcChannelConf.Rank = ADC_RANK_CHANNEL_NUMBER; /* Enable the rank of the selected channels when not fully configurable */
895+
#else
889896
AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */
897+
#endif
890898
#if !defined(STM32L0xx)
891899
#if !defined(STM32G0xx)
892900
AdcChannelConf.SamplingTime = samplingTime; /* Sampling time value to be set for the selected channel */

0 commit comments

Comments
 (0)