Skip to content

Commit 49cfd38

Browse files
committed
[BUG] esp32 ledc skips first channel index #471
1 parent 20e4481 commit 49cfd38

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/drivers/hardware_specific/esp32/esp32_ledc_mcu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ void* _configure3PWM(long pwm_frequency,const int pinA, const int pinB, const in
224224

225225
int pins[3] = {pinA, pinB, pinC};
226226
for(int i = 0; i < 3; i++){
227-
group_channels_used[group]++;
228227
if(!_ledcAttachChannelAdvanced(pins[i], group_channels_used[group], group, pwm_frequency, _PWM_RES_BIT, false)){
229228
SIMPLEFOC_DEBUG("EP32-DRV: ERROR - Failed to configure pin:", pins[i]);
230229
return SIMPLEFOC_DRIVER_INIT_FAILED;
231230
}
232231

233232
params->channels[i] = static_cast<ledc_channel_t>(group_channels_used[group]);
234233
params->groups[i] = (ledc_mode_t)group;
234+
group_channels_used[group]++;
235235
}
236236
SIMPLEFOC_DEBUG("EP32-DRV: 3PWM setup successful in group: ", (group));
237237
return params;

0 commit comments

Comments
 (0)