Skip to content

Commit c851a06

Browse files
committed
Fix overflow calculation for reload_value.
Please, note that this patch fixes upstream bug. See: https://devzone.nordicsemi.com/f/nordic-q-a/51674/maximum-reload-time-for-wdt
1 parent c9370f3 commit c851a06

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/watchdog_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ watchdog_status_t hal_watchdog_stop(void)
6969
uint32_t hal_watchdog_get_reload_value(void)
7070
{
7171
// Convert to milliseconds from 32768 Hz clock ticks.
72-
return nrf_wdt_reload_value_get() / 32768U * 1000;
72+
return (uint64_t)nrf_wdt_reload_value_get() / 32768U * 1000;
7373
}
7474

7575
watchdog_features_t hal_watchdog_get_platform_features(void)

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/drivers/src/nrfx_wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ nrfx_err_t nrfx_wdt_init(nrfx_wdt_config_t const * p_config,
9090

9191
nrf_wdt_behaviour_set(p_config->behaviour);
9292

93-
nrf_wdt_reload_value_set((p_config->reload_value * 32768) / 1000);
93+
nrf_wdt_reload_value_set(((uint64_t)p_config->reload_value * 32768) / 1000);
9494

9595
NRFX_IRQ_PRIORITY_SET(WDT_IRQn, p_config->interrupt_priority);
9696
NRFX_IRQ_ENABLE(WDT_IRQn);

0 commit comments

Comments
 (0)