Skip to content

Commit efeb52c

Browse files
committed
Add option to not use polling mode at low rpm
1 parent 79f3ec5 commit efeb52c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Src/main.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,11 @@ void commutate()
812812
}
813813
__enable_irq();
814814
changeCompInput();
815-
// if (average_interval > 2500) {
816-
// old_routine = 1;
817-
// }
815+
#ifndef NO_POLLING_START
816+
if (average_interval > 2500) {
817+
old_routine = 1;
818+
}
819+
#endif
818820
bemfcounter = 0;
819821
zcfound = 0;
820822
commutation_intervals[step - 1] = commutation_interval; // just used to calulate average
@@ -1499,17 +1501,24 @@ void zcfoundroutine()
14991501
bad_count = 0;
15001502

15011503
zero_crosses++;
1504+
#ifdef NO_POLLING_START // changes to interrupt mode after 30 zero crosses, does not re-enter
1505+
if (zero_crosses > 30) {
1506+
old_routine = 0;
1507+
enableCompInterrupts(); // enable interrupt
1508+
}
1509+
#else
15021510
if (eepromBuffer.stall_protection || eepromBuffer.rc_car_reverse) {
15031511
if (zero_crosses >= 20 && commutation_interval <= 2000) {
15041512
old_routine = 0;
15051513
enableCompInterrupts(); // enable interrupt
15061514
}
15071515
} else {
1508-
if (zero_crosses > 30) {
1516+
if (commutation_interval < 2000) {
15091517
old_routine = 0;
15101518
enableCompInterrupts(); // enable interrupt
15111519
}
15121520
}
1521+
#endif
15131522
}
15141523
#ifdef BRUSHED_MODE
15151524
void runBrushedLoop()

0 commit comments

Comments
 (0)