diff --git a/arch/risc-v/src/common/espressif/esp_ledc.c b/arch/risc-v/src/common/espressif/esp_ledc.c index cbc791b681167..7a310133bcda8 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) {