diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index c563da8da8..166d5c8882 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -435,9 +435,9 @@ void pwmWriteDshotCommand(uint8_t index, uint8_t motorCount, uint8_t command, bo } delayMicroseconds(timeDelayUs); } else { - for (uint8_t i = 0; i < motorCount; i++) { - if ((i == index) || (index == ALL_MOTORS)) { - if (dshotCommandControl.command[i] == 0) { + if (!pwmIsProcessingDshotCommand()) { + for (uint8_t i = 0; i < motorCount; i++) { + if ((index == i) || (index == ALL_MOTORS)) { dshotCommandControl.command[i] = command; dshotCommandControl.repeats = repeats; dshotCommandControl.nextCommandAt = timeNowUs + DSHOT_COMMAND_DELAY_US; @@ -458,11 +458,11 @@ uint8_t pwmGetDshotCommand(uint8_t index) return dshotCommandControl.command[index]; } -bool pwmProcessDshotCommand(uint8_t motorCount) +bool FAST_CODE_NOINLINE pwmProcessDshotCommand(uint8_t motorCount) { timeUs_t timeNowUs = micros(); if (cmpTimeUs(timeNowUs, dshotCommandControl.nextCommandAt) < 0) { - return true; //Skip motor update because it isn't time yet for a new command + return false; //Skip motor update because it isn't time yet for a new command } //Timed motor update happening with dshot command @@ -480,7 +480,7 @@ bool pwmProcessDshotCommand(uint8_t motorCount) dshotCommandControl.delayAfterCommand = 0; } - return false; + return true; } FAST_CODE uint16_t prepareDshotPacket(motorDmaOutput_t *const motor, const uint16_t value) diff --git a/src/main/drivers/pwm_output_dshot.c b/src/main/drivers/pwm_output_dshot.c index c9401ffde7..43b94480fc 100644 --- a/src/main/drivers/pwm_output_dshot.c +++ b/src/main/drivers/pwm_output_dshot.c @@ -97,7 +97,7 @@ void pwmCompleteDshotMotorUpdate(uint8_t motorCount) UNUSED(motorCount); /* If there is a dshot command loaded up, time it correctly with motor update*/ - if (pwmProcessDshotCommand(motorCount)) { + if (!pwmProcessDshotCommand(motorCount)) { return; //Skip motor update } diff --git a/src/main/drivers/pwm_output_dshot_hal.c b/src/main/drivers/pwm_output_dshot_hal.c index 46170521cf..e0ba048639 100644 --- a/src/main/drivers/pwm_output_dshot_hal.c +++ b/src/main/drivers/pwm_output_dshot_hal.c @@ -90,11 +90,12 @@ FAST_CODE void pwmCompleteDshotMotorUpdate(uint8_t motorCount) UNUSED(motorCount); /* If there is a dshot command loaded up, time it correctly with motor update*/ - if (pwmProcessDshotCommand(motorCount)) { - return; //Skip motor update + if (pwmIsProcessingDshotCommand()) { + if (!pwmProcessDshotCommand(motorCount)) { + return; + } } - for (int i = 0; i < dmaMotorTimerCount; i++) { #ifdef USE_DSHOT_DMAR if (useBurstDshot) {