diff --git a/libraries/AP_HAL_PX4/Scheduler.cpp b/libraries/AP_HAL_PX4/Scheduler.cpp index 2c0d6b68ed..e70df95adb 100644 --- a/libraries/AP_HAL_PX4/Scheduler.cpp +++ b/libraries/AP_HAL_PX4/Scheduler.cpp @@ -90,8 +90,9 @@ void PX4Scheduler::delay_microseconds(uint16_t usec) } perf_begin(_perf_delay); uint32_t start = micros(); - while (micros() - start < usec) { - up_udelay(usec - (micros() - start)); + uint32_t dt; + while ((dt=(micros() - start)) < usec) { + up_udelay(usec - dt); } perf_end(_perf_delay); }