Skip to content

Commit ce74bb5

Browse files
authored
Merge pull request #11178 from Tharazi97/watchdog_max_timeout
ST: Watchdog: Fix timeout registers value calculation
2 parents 398515a + df43350 commit ce74bb5

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)