Skip to content
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

analogRead() does not properly handle values 8..15 on Grand Central. #236

Open
WestfW opened this issue Jul 18, 2020 · 1 comment
Open

Comments

@WestfW
Copy link

WestfW commented Jul 18, 2020

The code in analogRead() does not not handle integer arguments of 8..15, which are valid analog pins on Grand Central. Worse, it will do "bad things", like setting PINMUX to "analog" on pins that don't even have analog support.

https://forums.adafruit.com/viewtopic.php?f=63&t=157146
https://forums.adafruit.com/viewtopic.php?f=63&t=167446

There's enough special code in analogRead() already that it really ought to handle this as well. It should at least not do bad things (and doing the right thing is just as easy...)

I have a patch and will submit a pull-request.

WestfW added a commit to WestfW-patches/AdadfruitCore-samd that referenced this issue Jul 18, 2020
@WestfW
Copy link
Author

WestfW commented Jul 18, 2020

This "bug" exists on other platforms with more than 8 analog inputs as well (CircuitPlaygroundExpress, for example), since the analogRead() code only adds the offset for n<=5, n=6, and n=7.
On all of them, A0..An are contiguous, so it doesn't NEED the (p-8)+A8 math. But it won't hurt, either. (and actually, it gets eliminated by the optimizer.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant