From c3d03f02fb6408ca7cbe90bcb6074ef27671fc3a Mon Sep 17 00:00:00 2001 From: Eren Terzioglu Date: Mon, 9 Dec 2024 12:20:42 +0100 Subject: [PATCH] esp32[c3|c6|h2]: Fix ledc clk issue --- arch/risc-v/src/common/espressif/esp_ledc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/common/espressif/esp_ledc.c b/arch/risc-v/src/common/espressif/esp_ledc.c index cbc791b6811..7a310133bcd 100644 --- a/arch/risc-v/src/common/espressif/esp_ledc.c +++ b/arch/risc-v/src/common/espressif/esp_ledc.c @@ -824,11 +824,16 @@ static int ledc_set_timer_div(ledc_timer_t timer_num, pwmerr("Timer clock conflict. Already is %d but attempt to %d", p_ledc_obj->glb_clk, glb_clk); - return -EINVAL; } } } + if (timer_num == LEDC_TIMER_MAX - 1 && + p_ledc_obj->glb_clk_is_acquired[timer_num - 1]) + { + return -EINVAL; + } + p_ledc_obj->glb_clk_is_acquired[timer_num] = true; if (p_ledc_obj->glb_clk != glb_clk) {