From 49cfd3804483ffc09614c4747d7d135bb9f6799a Mon Sep 17 00:00:00 2001 From: runger1101001 Date: Wed, 21 May 2025 18:19:32 +0200 Subject: [PATCH] [BUG] esp32 ledc skips first channel index #471 --- src/drivers/hardware_specific/esp32/esp32_ledc_mcu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/hardware_specific/esp32/esp32_ledc_mcu.cpp b/src/drivers/hardware_specific/esp32/esp32_ledc_mcu.cpp index dc667ab3..ea830ea2 100644 --- a/src/drivers/hardware_specific/esp32/esp32_ledc_mcu.cpp +++ b/src/drivers/hardware_specific/esp32/esp32_ledc_mcu.cpp @@ -224,7 +224,6 @@ void* _configure3PWM(long pwm_frequency,const int pinA, const int pinB, const in int pins[3] = {pinA, pinB, pinC}; for(int i = 0; i < 3; i++){ - group_channels_used[group]++; if(!_ledcAttachChannelAdvanced(pins[i], group_channels_used[group], group, pwm_frequency, _PWM_RES_BIT, false)){ SIMPLEFOC_DEBUG("EP32-DRV: ERROR - Failed to configure pin:", pins[i]); return SIMPLEFOC_DRIVER_INIT_FAILED; @@ -232,6 +231,7 @@ void* _configure3PWM(long pwm_frequency,const int pinA, const int pinB, const in params->channels[i] = static_cast(group_channels_used[group]); params->groups[i] = (ledc_mode_t)group; + group_channels_used[group]++; } SIMPLEFOC_DEBUG("EP32-DRV: 3PWM setup successful in group: ", (group)); return params;