-
-
Notifications
You must be signed in to change notification settings - Fork 725
digitalWrite() unnecessarily activates the pull-up resistor on the specified pin #94
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
Comments
I also commented out that line in digitalWrite(), since our custom board has its own pull-up resistors and it was just unnecessarily pulling down the current on many of the lines. PIO_INPUT, /* The pin is controlled by PORT and is an input. */
PIO_INPUT_PULLUP, /* The pin is controlled by PORT and is an input with internal pull-up resistor enabled. */
PIO_OUTPUT, /* The pin is controlled by PORT and is an output. */ I think it might be prudent to add one more PIO type here, PIO_OUTPUT_PULLUP, and have the functions in the wiring files respect that, or add a separate property in the pin description structure for resistor configuration altogether. Nothing critical, but it had me scratching my head for a bit, wondering why my LED was barely turning on. |
@dirk67 the goal of enabling the pull-up was to maintain compatibility with AVR core behaviour: The following is equivalent to
However, as you mentioned above, the core is currently clears input enable, so this does not work. @dirk67 @spiderkeys I've submitted #101 to resolve this, please review and/or test it out if you have time. |
…digitalWrite if pin is not output. arduino#56 arduino#79 arduino#94 arduino#101
Closing since #101 is merged now. |
digitalWrite() unnecessarily activates the pull-up resistor on the specified pin.
the issue with the pull-up in digitalWrite(),
(other than the fact that this line shouldn't be there),
is because the pin configuration register (PINCFG) isn't logically ORed with the bit mask when the pull-up bit (PULLEN) is enabled,
instead the mask is copied directly into the register.
This effectively clears all the other bits in the register including the input enable (INEN).
in addition this issue makes the code not forward/backward compatible to AVR code
(digitalRead therefore cannot read back the current value of a digital PIN configured as OUTPUT.)
--> https://forum.arduino.cc/index.php?topic=367517.msg2534096#msg2534096
--> http://forum.arduino.cc/index.php?topic=334073.msg2306580#msg2306580
The text was updated successfully, but these errors were encountered: