From b9664f404851f312ed61af512eade924f32a9ef6 Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 15 May 2024 11:42:06 +0200 Subject: [PATCH] fix(ledc): Match channel number with groups --- cores/esp32/esp32-hal-ledc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index de164c9a4b9..8c9454c996f 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -92,7 +92,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c return false; } - uint32_t duty = ledc_get_duty(group, channel); + uint32_t duty = ledc_get_duty(group, (channel % 8)); ledc_channel_config_t ledc_channel = { .speed_mode = group, .channel = (channel % 8), .timer_sel = timer, .intr_type = LEDC_INTR_DISABLE, .gpio_num = pin, .duty = duty, .hpoint = 0