stm32:iwdg: reset counter after changing period.

Fix the bug that the iwdg counter is not refreshed after the configurationis complete, if this counter is not refreshed after the configuration is completed, the first iwdg counting period will be as long as 26 seconds.

Fixes: https://github.com/libopencm3/libopencm3/pull/1333
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
This commit is contained in:
weycen76
2021-04-30 20:33:47 +08:00
committed by Karl Palsson
parent 6f9f40a7e4
commit 12da5bbd9e

View File

@@ -108,6 +108,9 @@ void iwdg_set_period_ms(uint32_t period)
while (iwdg_reload_busy());
IWDG_KR = IWDG_KR_UNLOCK;
IWDG_RLR = count & COUNT_MASK;
/* Refresh counter after configuration is complete */
iwdg_reset();
}
/*---------------------------------------------------------------------------*/