diff --git a/user/tests/wiring/no_fixture/delay.cpp b/user/tests/wiring/no_fixture/delay.cpp index 56ec387bf8..df2b470666 100644 --- a/user/tests/wiring/no_fixture/delay.cpp +++ b/user/tests/wiring/no_fixture/delay.cpp @@ -19,8 +19,15 @@ class DelayTest } }; -test(DELAY_01_delay_1_is_within_5_percent) +test(DELAY_01_delay_1ms_is_within_tolerance) { + // These errors are mainly due to processing overhead, which is a greater factor on NRF with a slower clock speed +#if HAL_PLATFORM_NRF52840 + const uint32_t delay_us_error = 200; // 20% +#else + const uint32_t delay_us_error = 50; // 5% +#endif + DelayTest dt(10); // on RTOS have to stop task scheduling for the delays or we may not // be executed often enough @@ -31,7 +38,8 @@ test(DELAY_01_delay_1_is_within_5_percent) uint32_t end = micros(); scheduler(true); + // Serial.printlnf("total time:%lu", end-start); assertMoreOrEqual(end-start, 1000); - assertLessOrEqual(end-start, 1050); + assertLessOrEqual(end-start, 1000 + delay_us_error); } } \ No newline at end of file