iwdg: START and UNLOCK values before polling Busy

With code that uses IWDG and these operations:

- user code initializes iwdg
- user code jumps to USB-DFU
- USB host triggers a USB exit (e.g. after reflashing, or even just a
  dummy dfu-util Reset/Exit command)
- user code will hang in iwdg_prescaler_busy() called from
  iwdg_set_period_ms()
This commit is contained in:
fenugrec
2025-04-17 22:16:06 -04:00
committed by Piotr Esden-Tempski
parent 9624f92d81
commit a7632df7f4

View File

@@ -102,11 +102,11 @@ void iwdg_set_period_ms(uint32_t period)
prescale = PRESCALER_MAX;
}
while (iwdg_prescaler_busy());
IWDG_KR = IWDG_KR_START;
IWDG_KR = IWDG_KR_UNLOCK;
while (iwdg_prescaler_busy());
IWDG_PR = prescale;
while (iwdg_reload_busy());
IWDG_KR = IWDG_KR_UNLOCK;
IWDG_RLR = count & COUNT_MASK;
/* Refresh counter after configuration is complete */