mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-23 22:13:14 +03:00
On ESP32, duty_start stays set until a duty update or fade completes. ledc_ll_set_duty_start() waits for that bit inside ledc_spinlock, so writing new channel parameters while an update is still pending corrupts the in-flight operation and then spins with interrupts disabled until it finishes, which trips the interrupt watchdog. Wait for duty_start to clear in _ledc_fade_hw_acquire() with vTaskDelay, after taking the fade semaphore and masking DUTY_CHANGE_END, and before rewriting duty/fade registers. The wait also applies when fade service is not installed. Keep a short HAL wait as a last guard for ledc_update_duty(). ledc_set_duty_and_update() still returns before the new duty takes effect on the next PWM cycle. Merges https://github.com/espressif/esp-idf/pull/19077 Co-authored-by: Song Ruo Jing <songruojing@espressif.com> Co-authored-by: Cursor <cursoragent@cursor.com>