Skip to content

this closes issue #2198 #2486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

this closes issue #2198 #2486

wants to merge 1 commit into from

Conversation

agdl
Copy link
Member

@agdl agdl commented Dec 5, 2014

In this way the problem doesn't subsist any more because pinMode checks if pin is digital and if so disable ADC when pin is declared as OUTPUT and enable it if declared as INPUT

If an analog input is used and during the sketch modified in a digitalOutput
the pinMode(AX, OUTPUT) isn't sensed because of this line of codes:

wiring_analog.c line 135
// Enable the corresponding channel
	if (ulChannel != latestSelectedChannel) {
		adc_enable_channel( ADC, ulChannel );
		if ( latestSelectedChannel != (uint32_t)-1 )
			adc_disable_channel( ADC, latestSelectedChannel );
		latestSelectedChannel = ulChannel;

The channel is infact enabled only if different from the previous one because
of speed problems.

With my patch:

when pinMode(PIN, OUTPUT) is declared a control about if the pin
is an analog one is done and if so the ADC is released

when pinMode(PIN, INPUT) is declared a control is as well done in order to
enable the ADC.
@ffissore
Copy link
Contributor

ffissore commented Jan 8, 2015

@ArduinoBot build this please

@ffissore ffissore added Component: Core Related to the code for the standard Arduino API Board: Arduino Due Applies only to the Due labels Mar 12, 2015
@facchinm
Copy link
Member

@facchinm facchinm added the Waiting for feedback More information must be provided before we can proceed label Mar 23, 2015
@facchinm
Copy link
Member

Closing because the solution has the side effect to break digitalRead() on analog pins.
Discussion on the fix continues in the mailing list

@facchinm facchinm closed this Mar 26, 2015
@agdl agdl deleted the ide-1.5.x branch March 18, 2016 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Board: Arduino Due Applies only to the Due Component: Core Related to the code for the standard Arduino API Waiting for feedback More information must be provided before we can proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants