Modified version of the Watchdog library with improved support for STM32
Dependents: LightSaber iot_water_monitor_v2
Fork of Watchdog by
Diff: Watchdog.cpp
- Revision:
- 8:3c7d083f26b5
- Parent:
- 7:8912bb017956
- Child:
- 9:84f7c088c261
--- a/Watchdog.cpp Tue Oct 27 16:02:33 2015 +0000 +++ b/Watchdog.cpp Tue Oct 27 17:04:16 2015 +0000 @@ -95,6 +95,11 @@ int scale = 1 + log2(s / 4096); // The RLR register is 12 bits and beyond that a prescaler should be used int residual = s / (1 << scale); // The value for the RLR register + if (scale > 8) { //STM32 allows a maximum time of around 26.2 seconds for the Watchdog timer + scale = 8; + residual = 0xFFF; + } + IWDG->KR = 0x5555; // enable write to PR, RLR IWDG->PR = scale - 2; // Prescaler has values of multiples of 4 (i.e. 2 ^2), page 486 Reference Manual IWDG->RLR = residual; // Init RLR