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

Fix blink example by correctly toggling output #79

Merged
merged 1 commit into from
Aug 19, 2022

Conversation

wnienhaus
Copy link
Collaborator

The blink example was toggling the GPIOs "output enable" state, instead of keeping "output enable" on and then toggling the output value of the pin. (reported in #78)

This PR fixes the problem by enabling "output enable" at the start, and then only toggling the output value of the pin "on" and "off". (Documentation for the used register constants can be found here and here)

The change was tested with a logic analyser to confirm the expected change.

More details in the commit message.

Resolves issue #78.

The blink example was incorrect (as pointed out in issue micropython#78).

The example was toggling the GPIOs "output enable" state,
instead of keeping "output enable" on and then toggling the
output value of the pin.

It "accidentally" worked, because we initally set the output
value to 1 (high) and thus, whenever "output enable" was set,
the LED lit up, and when "output enable" was turned off, the
pin was left floating without any output voltage and the LED
therefore turned off.

The new approach correctly enables "output enable" at the
start, and then only toggles the output value of the pin on
and off.

This change was also tested with a logic analyser, showing
that before this change, the logic analyser could not correcly
detect a LOW state after a HIGH state, because the pin was
floating without a pull-down resistor in place, whenever it
was not in "output enable" mode.

After this change, the logic analyser correctly detected all
LOW and HIGH states, because the pin remained in "output
enable" mode (and the ESP32 has a pull-down configured by
default) and only the output value was toggled.
@wnienhaus wnienhaus merged commit a752255 into micropython:master Aug 19, 2022
@wnienhaus wnienhaus deleted the fix_blink_example branch June 14, 2023 08:25
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

Successfully merging this pull request may close these issues.

None yet

1 participant