File tree 1 file changed +6
-2
lines changed
hardware/arduino/sam/cores/arduino
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)
130
130
#endif
131
131
132
132
#if defined __SAM3X8E__ || defined __SAM3X8H__
133
+ static uint32_t latestSelectedChannel = -1 ;
133
134
switch ( g_APinDescription [ulPin ].ulAnalogChannel )
134
135
{
135
136
// Handling ADC 12 bits channels
@@ -147,7 +148,10 @@ uint32_t analogRead(uint32_t ulPin)
147
148
case ADC11 :
148
149
149
150
// Enable the corresponding channel
150
- adc_enable_channel ( ADC , ulChannel );
151
+ if (ulChannel != latestSelectedChannel ) {
152
+ adc_enable_channel ( ADC , ulChannel );
153
+ latestSelectedChannel = ulChannel ;
154
+ }
151
155
152
156
// Start the ADC
153
157
adc_start ( ADC );
@@ -161,7 +165,7 @@ uint32_t analogRead(uint32_t ulPin)
161
165
ulValue = mapResolution (ulValue , ADC_RESOLUTION , _readResolution );
162
166
163
167
// Disable the corresponding channel
164
- adc_disable_channel (ADC , ulChannel );
168
+ // adc_disable_channel(ADC, ulChannel);
165
169
166
170
break ;
167
171
You can’t perform that action at this time.
0 commit comments