1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 21:05:35 +03:00

Fix motor twitch when unarmed and using synced protocols.

This commit is contained in:
blckmn 2017-07-15 14:51:59 +10:00
parent 6fe956dea0
commit f0bdc93a25

View file

@ -311,13 +311,14 @@ void motorDevInit(const motorDevConfig_t *motorConfig, uint16_t idlePulse, uint8
#endif #endif
/* standard PWM outputs */ /* standard PWM outputs */
const unsigned pwmRateHz = useUnsyncedPwm ? motorConfig->motorPwmRate : ceilf(1 / (sMin + sLen * 2)); // margin of safety is 4 periods when unsynced
const unsigned pwmRateHz = useUnsyncedPwm ? motorConfig->motorPwmRate : ceilf(1 / ((sMin + sLen) * 4));
const uint32_t clock = timerClock(timerHardware->tim); const uint32_t clock = timerClock(timerHardware->tim);
/* used to find the desired timer frequency for max resolution */ /* used to find the desired timer frequency for max resolution */
const unsigned prescaler = ((clock / pwmRateHz) + 0xffff) / 0x10000; /* rounding up */ const unsigned prescaler = ((clock / pwmRateHz) + 0xffff) / 0x10000; /* rounding up */
const uint32_t hz = clock / prescaler; const uint32_t hz = clock / prescaler;
const unsigned period = hz / pwmRateHz; const unsigned period = useUnsyncedPwm ? hz / pwmRateHz : 0xffff;
/* /*
if brushed then it is the entire length of the period. if brushed then it is the entire length of the period.