-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Pin not "writable" after tone() #5306
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 can confirm this. I modified the sketch to add a second pin to trigger a scope. The pin actually does go high but is then driven low less than 1ms later, I've seen 100us to 750us. I also tried adding a delay after #include <Arduino.h>
void setup() {
pinMode(D5, OUTPUT);
digitalWrite(D5, LOW); // Second scope channel used as trigger
pinMode(D6,OUTPUT);
digitalWrite(D6, HIGH); // the pin really goes HIGH
delay(5000);
tone(D6,1000,500);
delay(1500);
noTone(D6); // This makes no difference, I was thinking it is necessary to "release" the pin...
delay(1500);
pinMode(D6,OUTPUT);
digitalWrite(D5, HIGH); // trigger scope
digitalWrite(D6, HIGH); // pulses high and is changed low again after 750us
}
void loop() {
}
|
The ISR could end up writing a 0 to a GPIO that had previously been stopped, effectively overwriting user writes to those pins. Fix to only actually disable and write when a pin was enabled and times out. Fixes esp8266#5306
Thanks for the clear MCVE. The ISR was disabling the pin and writing 0 every time it was called, even if it was already disabled. Check the PR if you can, but I've verified it on my own logic analyzer. |
Yeah the fix works for me, thanks! I'm new with this procedure (pull request, complex versioning and so on...) but I would ask if this fix will be included in version 2.5. |
The ISR could end up writing a 0 to a GPIO that had previously been stopped, effectively overwriting user writes to those pins. Fix to only actually disable and write when a pin was enabled and times out. Fixes #5306
PR is merged. |
Basic Infos
Platform
Settings in IDE
Problem Description
I'm using tone(..) function to play some melodies on a passive buzzer (this is my breakout: https://robotdyn.com/buzzer-module.html). After the melody, I should standby the buzzer to save energy, so I have to write 1 on the digital pin. I observed that after the tone function is impossible to command that pin, it stays low. The problem is not hardware, since this behaviour is observable even without a buzzer...
MCVE Sketch
The text was updated successfully, but these errors were encountered: