Skip to content

Commit 3745c73

Browse files
committed
set the tolerance to 5% if NO_SYSTICK is enabled
1 parent 24cebba commit 3745c73

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

TESTS/mbed_drivers/timer/main.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ extern uint32_t SystemCoreClock;
4545
* 1000 ms delay: tolerance = 20500 us
4646
*
4747
* */
48-
#define DELTA_US(delay_ms) (500 + (delay_ms) * US_PER_MSEC / 50)
49-
#define DELTA_MS(delay_ms) (1 + ((delay_ms) * US_PER_MSEC / 50 / US_PER_MSEC))
50-
#define DELTA_S(delay_ms) (0.000500f + (((float)(delay_ms)) / MSEC_PER_SEC / 50))
48+
#ifdef NO_SYSTICK
49+
#define TOLERANCE 5
50+
#else
51+
#define TOLERANCE 2
52+
#endif
53+
54+
#define DELTA_US(delay_ms) (500 + (delay_ms) * US_PER_MSEC * TOLERANCE / 100)
55+
#define DELTA_MS(delay_ms) (1 + (delay_ms) * TOLERANCE / 100)
56+
#define DELTA_S(delay_ms) (0.000500f + ((float)(delay_ms)) * ((float)(TOLERANCE) / 100.f) / MSEC_PER_SEC)
5157

5258
#define TICKER_FREQ_1MHZ 1000000
5359
#define TICKER_BITS 32

0 commit comments

Comments
 (0)