File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
TESTS/mbed_drivers/lp_timer Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,17 @@ extern uint32_t SystemCoreClock;
51
51
* For K64F DELTA = (80000 / 120000000) * 1000000 = 666[us]
52
52
* For NUCLEO_F070RB DELTA = (80000 / 48000000) * 1000000 = 1666[us]
53
53
* 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
54
57
*/
55
58
#define US_PER_SEC 1000000
56
59
#define US_PER_MSEC 1000
57
60
#define TOLERANCE_FACTOR 80000 .0f
58
61
#define US_FACTOR 1000000 .0f
62
+ #define CLOCK_MAX 130000000
59
63
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) ));
61
65
62
66
/* When test performs time measurement using Timer in sequence, then measurement error accumulates
63
67
* in the successive attempts. */
You can’t perform that action at this time.
0 commit comments