Closed
Description
Board
ESP32 (classic)
Device Description
ESP32-classic
Hardware Configuration
Nothing attached to the board
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
40MHz
PSRAM enabled
yes
Upload speed
115200
Description
Several calls to ledcAttach
followed by ledcFade
on the same pin without calling ledcDetach
for that pin will lead to a completely frozen system on ESP32.
N.B. the same code on ESP32-C2 does not show this behavior. Not tested on other ESP32-variants.
Since there doesn't seem to be a simple check to see if a pin is already attached, I added a simple ledcWrite
check first to set the start duty cycle for the upcoming fade.
If this returns false, I run ledcAttach
on that pin.
So either of these 2 variants do work:
if (!ledcWrite(gpio, start_duty)) {
// Pin not yet attached
if (!ledcAttach(gpio, frequency, resolution)) {
return false;
}
}
if (!ledcFade(gpio, start_duty, target_duty, fadeDuration_ms)) {
return false;
}
ledcDetach(gpio);
if (!ledcAttach(gpio, frequency, resolution)) {
return false;
}
if (!ledcFade(gpio, start_duty, target_duty, fadeDuration_ms)) {
return false;
}
Sketch
// Not working code
while (true) {
if (ledcAttach(gpio, frequency, resolution)) {
ledcFade(gpio, start_duty, target_duty, fadeDuration_ms);
}
delay(2*fadeDuration_ms);
}
Debug Message
Node just freezes after a few calls
Probably due to the semaphore code in ledcFadeConfig
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.