Skip to content

Commit df43350

Browse files
committed
Tweak STM watchdog implementation
Change the calculation method of rl so it is rounded up.
1 parent 0a73eda commit df43350

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

targets/TARGET_STM/watchdog_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// Convert Prescaler_divider bits (PR) of Prescaler_register (IWDG_PR) and a timeout value [ms]
4040
// to Watchdog_counter_reload_value bits (RL) of Reload_register (IWDG_RLR)
4141
#define PR_TIMEOUT_MS2RL(PR_BITS, TIMEOUT_MS) \
42-
((TIMEOUT_MS) * (LSI_VALUE) / (PR2PRESCALER_DIV(PR_BITS)) / 1000UL)
42+
(((TIMEOUT_MS) * (LSI_VALUE) / (PR2PRESCALER_DIV(PR_BITS)) + 999UL) / 1000UL)
4343

4444
#define MAX_TIMEOUT_MS_UINT64 PR_RL2UINT64_TIMEOUT_MS(MAX_IWDG_PR, MAX_IWDG_RL)
4545
#if (MAX_TIMEOUT_MS_UINT64 > UINT32_MAX)

0 commit comments

Comments
 (0)