From da70c886c1e9c247851dda998a2fbe7c1e2aa183 Mon Sep 17 00:00:00 2001 From: int_szyk Date: Tue, 6 Aug 2019 14:15:17 +0200 Subject: [PATCH] tweak watchdog kick reset test Change the value of KICK_ADVANCE_MS so targets pass the test in worst cases --- TESTS/mbed_drivers/watchdog_reset/main.cpp | 16 +++++++++++++++- TESTS/mbed_hal/watchdog_reset/main.cpp | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/TESTS/mbed_drivers/watchdog_reset/main.cpp b/TESTS/mbed_drivers/watchdog_reset/main.cpp index 3f6e3d9a0fe..0732d98fa43 100644 --- a/TESTS/mbed_drivers/watchdog_reset/main.cpp +++ b/TESTS/mbed_drivers/watchdog_reset/main.cpp @@ -26,7 +26,21 @@ #include "mbed.h" #define TIMEOUT_MS 100UL -#define KICK_ADVANCE_MS 10UL + +/* This value is used to calculate the time to kick the watchdog. + * Given the watchdog timeout is set to TIMEOUT_MS, the kick will be performed + * with a delay of (TIMEOUT_MS - KICK_ADVANCE_MS), after the init. + * + * It is common for the watchdog peripheral to use a low precision clock source, + * e.g. the LSI RC acts as a clock source for the IWDG on ST targets. + * According to the ST spec, the 37 kHz LSI is guaranteed to have a frequency + * around 37-38 kHz, but the actual frequency range guaranteed by the production + * tests is 26 kHz up to 56 kHz. + * Bearing that in mind, a 100 ms timeout value may actually last as long as 142 ms + * and as short as 66 ms. + * The value of 35 ms is used to cover the worst case scenario (66 ms). + */ +#define KICK_ADVANCE_MS 35UL #define MSG_VALUE_DUMMY "0" #define CASE_DATA_INVALID 0xffffffffUL diff --git a/TESTS/mbed_hal/watchdog_reset/main.cpp b/TESTS/mbed_hal/watchdog_reset/main.cpp index 1c94a91b3f1..7300392ddce 100644 --- a/TESTS/mbed_hal/watchdog_reset/main.cpp +++ b/TESTS/mbed_hal/watchdog_reset/main.cpp @@ -26,7 +26,21 @@ #include "mbed.h" #define TIMEOUT_MS 100UL -#define KICK_ADVANCE_MS 10UL + +/* This value is used to calculate the time to kick the watchdog. + * Given the watchdog timeout is set to TIMEOUT_MS, the kick will be performed + * with a delay of (TIMEOUT_MS - KICK_ADVANCE_MS), after the init. + * + * It is common for the watchdog peripheral to use a low precision clock source, + * e.g. the LSI RC acts as a clock source for the IWDG on ST targets. + * According to the ST spec, the 37 kHz LSI is guaranteed to have a frequency + * around 37-38 kHz, but the actual frequency range guaranteed by the production + * tests is 26 kHz up to 56 kHz. + * Bearing that in mind, a 100 ms timeout value may actually last as long as 142 ms + * and as short as 66 ms. + * The value of 35 ms is used to cover the worst case scenario (66 ms). + */ +#define KICK_ADVANCE_MS 35UL #define MSG_VALUE_DUMMY "0" #define CASE_DATA_INVALID 0xffffffffUL