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

Toggle should use output register, not pin state #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tombrazier
Copy link

See discussion in MarlinFirmware/Marlin#27341.

Function pin_type::toggle() reads a value from gpio_reg().reg_control (known as FIOPIN in the LPC1768 manual chapter 9), modifies it and then writes it back to gpio_reg().reg_control. On writing, this updates the output register for GPIO. However the value read actually reads the pin state, not the output register.

It is possible when toggling pins in quick succession for a race condition to exist where a pin's output state is still reading an old value when gpio_reg().reg_control is read, resulting in lost pin changes.

To read the output register, one must read gpio_reg().reg_set (FIOSET in the LPC1768 manual).

I am not able to test this PR because I do not have an LPC1768 board but I have a report from MarlinFirmware/Marlin#27341 that it works.

@tombrazier
Copy link
Author

I now have multiple reports of this PR fixing the issue in Marlin.

@p3p
Copy link
Owner

p3p commented Nov 18, 2024

Thanks I will get this merged and a release done as soon as I can

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.

2 participants