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

How are pin default pull downs working? #367

Closed
microbit-carlos opened this issue Aug 11, 2023 · 1 comment
Closed

How are pin default pull downs working? #367

microbit-carlos opened this issue Aug 11, 2023 · 1 comment

Comments

@microbit-carlos
Copy link
Collaborator

On issue #357 we agreed that for V1 compatibility the pin pull downs should be enabled by default, as also discussed in #17.

Looking at NRF52Pin, it is probably achieved by having the default state in target.json/target-locked.json:

"DEVICE_DEFAULT_PULLMODE":"PullMode::Down",

And that being applied in the NRF52Pin constructor. But this only sets the internal state of the NRF52Pin instance, it is only applied on first usage of get/setDigitalValue, when the setPull method is actually called:

However the MicroBitIO constructor, which will be executed after all the NRF52Pins have been constructed, it sets the internal pull state of the edge connector pins to PullNone and applies it:

// Ensure all internal pins are configured with no pull resistors.
for (int i=19; i<pins; i++)
pin[i].setPull(PullMode::None);

So not 100% sure how the pull downs are configured by default.

@microbit-carlos
Copy link
Collaborator Author

Argh, as I re-read the issue, I notice that the loop is actually from pin19 forward, so we are good and there is no issue here 🙈

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