Skip to content

Commit 9a43912

Browse files
committed
lp_timer test : add a minimum delta value
1 parent 9ebefcd commit 9a43912

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

TESTS/mbed_drivers/lp_timer/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ extern uint32_t SystemCoreClock;
5151
* For K64F DELTA = (80000 / 120000000) * 1000000 = 666[us]
5252
* For NUCLEO_F070RB DELTA = (80000 / 48000000) * 1000000 = 1666[us]
5353
* For NRF51_DK DELTA = (80000 / 16000000) * 1000000 = 5000[us]
54+
*
55+
* As low power timer cannot be too much accurate, this DELTA should not be more precise than 500us,
56+
* which corresponds to a maximum CPU clock around 130MHz
5457
*/
5558
#define US_PER_SEC 1000000
5659
#define US_PER_MSEC 1000
5760
#define TOLERANCE_FACTOR 80000.0f
5861
#define US_FACTOR 1000000.0f
62+
#define CLOCK_MAX 130000000
5963

60-
static const int delta_sys_clk_us = ((int) (TOLERANCE_FACTOR / (float) SystemCoreClock * US_FACTOR));
64+
static const int delta_sys_clk_us = (SystemCoreClock < CLOCK_MAX? ((int) (TOLERANCE_FACTOR / (float) SystemCoreClock * US_FACTOR)):((int) (TOLERANCE_FACTOR / (float) CLOCK_MAX * US_FACTOR)));
6165

6266
/* When test performs time measurement using Timer in sequence, then measurement error accumulates
6367
* in the successive attempts. */

0 commit comments

Comments
 (0)