-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
v3.0.0: Calling digitalWrite() inside ISR May Crash Due to Lack of IRAM_ATTR in _stopPWM() #8043
Comments
Did you try to add |
@d-a-v Yes. I've tried it on my local ESP8266 Arduino core installation. It worked. That's how I found that it's the problem of lack of IRAM_ATTR in _stopPWM(). |
Thanks ! |
@d-a-v Cool. I'll do it today. Will send you a pull request after I'm done. |
@d-a-v Pull request ready. Please review. |
@d-a-v I think there are more code paths depending on the selected PWM generator that need the attribute. Can this issue be reopened, please? |
Basic Infos
Platform
Settings in IDE
Problem Description
digitalWrite() calls _stopPWM(), which lacks the IRAM_ATTR attribute.
When digitalWrite() is called inside an ISR handler, it may have to wait for the content get fetched from the external flash, which'd block the ISR handler, which may cause the system to crash.
Relevant code: https://github.com/esp8266/Arduino/blob/90f611f/cores/esp8266/core_esp8266_waveform_pwm.cpp#L263
This bug can be easily reproduced if you read the flash filesystem while running digitalWrite() in ISR frequently. For the ease of implementation, the MCVE uses the ESP8266TimerInterrupt library.
This bug is new in v3.0.0 and couldn't be reproduced in v2.7.4.
MCVE Sketch
Stack Dump
The text was updated successfully, but these errors were encountered: