File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
hardware/arduino/sam/cores/arduino Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ uint32_t analogRead(uint32_t ulPin)
130130#endif
131131
132132#if defined __SAM3X8E__ || defined __SAM3X8H__
133+ static uint32_t latestSelectedChannel = -1 ;
133134 switch ( g_APinDescription [ulPin ].ulAnalogChannel )
134135 {
135136 // Handling ADC 12 bits channels
@@ -147,7 +148,10 @@ uint32_t analogRead(uint32_t ulPin)
147148 case ADC11 :
148149
149150 // Enable the corresponding channel
150- adc_enable_channel ( ADC , ulChannel );
151+ if (ulChannel != latestSelectedChannel ) {
152+ adc_enable_channel ( ADC , ulChannel );
153+ latestSelectedChannel = ulChannel ;
154+ }
151155
152156 // Start the ADC
153157 adc_start ( ADC );
@@ -161,7 +165,7 @@ uint32_t analogRead(uint32_t ulPin)
161165 ulValue = mapResolution (ulValue , ADC_RESOLUTION , _readResolution );
162166
163167 // Disable the corresponding channel
164- adc_disable_channel (ADC , ulChannel );
168+ // adc_disable_channel(ADC, ulChannel);
165169
166170 break ;
167171
You can’t perform that action at this time.
0 commit comments