Skip to content

Commit a1d5b86

Browse files
Merge pull request #480 from runger1101001/dev
esp32 ledc skips first channel index #471
2 parents 0205da7 + 27091b1 commit a1d5b86

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
@@ -235,14 +235,14 @@ void* _configure3PWM(long pwm_frequency,const int pinA, const int pinB, const in
235235

236236
int pins[3] = {pinA, pinB, pinC};
237237
for(int i = 0; i < 3; i++){
238-
group_channels_used[group]++;
239238
if(!_ledcAttachChannelAdvanced(pins[i], group_channels_used[group], group, pwm_frequency, _PWM_RES_BIT, false)){
240239
SIMPLEFOC_DEBUG("EP32-DRV: ERROR - Failed to configure pin:", pins[i]);
241240
return SIMPLEFOC_DRIVER_INIT_FAILED;
242241
}
243242

244243
params->channels[i] = static_cast<ledc_channel_t>(group_channels_used[group]);
245244
params->groups[i] = (ledc_mode_t)group;
245+
group_channels_used[group]++;
246246
}
247247
SIMPLEFOC_DEBUG("EP32-DRV: 3PWM setup successful in group: ", (group));
248248
return params;

0 commit comments

Comments
 (0)