Skip to content

Commit c507b71

Browse files
committed
fix for ESP32 C6 with >1 motors
1 parent f6362e7 commit c507b71

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/drivers/hardware_specific/esp32/esp32_driver_mcpwm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ uint8_t _findNextTimer(int group){
181181
*/
182182
int _findBestGroup(int no_pins, long pwm_freq, int* group, int* timer){
183183
// an empty group is always the best option
184-
for(int i=0; i<2; i++){
184+
for(int i=0; i<SOC_MCPWM_GROUPS; i++){
185185
if(!group_pins_used[i]){
186186
*group = i;
187187
*timer=0; // use the first timer in an empty group
@@ -196,15 +196,15 @@ int _findBestGroup(int no_pins, long pwm_freq, int* group, int* timer){
196196
// second best option is if there is a group with
197197
// pair number of pwms available as we can then
198198
// set the pwm frequency
199-
for(int i=0; i<2; i++){
199+
for(int i=0; i<SOC_MCPWM_GROUPS; i++){
200200
if(_hasAvailablePins(i, no_pins+1)) {
201201
*group=i;
202202
*timer = _findNextTimer(i);
203203
return 1;
204204
}
205205
}
206206
// third best option is any group that has enough pins
207-
for(int i=0; i<2; i++){
207+
for(int i=0; i<SOC_MCPWM_GROUPS; i++){
208208
if(_hasAvailablePins(i, no_pins)) {
209209
*group=i;
210210
*timer = _findLastTimer(i);

0 commit comments

Comments
 (0)