Skip to content

digitalRead() broken on pins in output mode. #79

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
WestfW opened this issue Dec 28, 2015 · 3 comments
Closed

digitalRead() broken on pins in output mode. #79

WestfW opened this issue Dec 28, 2015 · 3 comments

Comments

@WestfW
Copy link

WestfW commented Dec 28, 2015

Apparently "pinMode(pin, OUTPUT)" will clear the INEN bit for the GPIO pin in question, preventing digitalRead() (or direct port access) from being able to read the current output state of an output pin, and breaking trivial statements like:
digitalWrite(13, ! digitalRead(13)); // toggle LED
As far as I can tell, there should never be a reason to disable input on the GPIO pins (PORT_PINCFG_INEN bit cleared in pincfg), except maybe when the pin is used for analog input.

http://forum.arduino.cc/index.php?topic=367517

@WestfW
Copy link
Author

WestfW commented Dec 28, 2015

(also be careful not to clear INEN when setting PULLEN)

@sandeepmistry
Copy link
Contributor

@WestfW agreed, I've submitted #101 to resolve this, please review or test it out if you have time.

mattairtech added a commit to mattairtech/ArduinoCore-samd that referenced this issue Mar 30, 2016
@sandeepmistry
Copy link
Contributor

Closing since #101 is merged now.

boseji pushed a commit to go-ut/combined-ArduinoCore-samd that referenced this issue May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants