STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
iwdg.h File Reference

IWDG driver: start, refresh and debug-freeze the independent watchdog. More...

#include "dbgmcu_reg.h"
#include "driver_status.h"
#include "iwdg_reg.h"
#include <stdint.h>
Include dependency graph for iwdg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

DRIVER_MUST_CHECK DriverStatus_e iwdgStart (IwdgRegisters_t *iwdg, uint32_t prescaler, uint32_t reload)
 Start the watchdog, then set its prescaler and reload value.
void iwdgRefresh (IwdgRegisters_t *iwdg)
 Reload the counter from RLR (KR = 0xAAAA).
void iwdgFreezeInDebug (DbgmcuRegisters_t *dbgmcu)
 Stop the IWDG counter whenever the core is halted by a debugger.

Detailed Description

IWDG driver: start, refresh and debug-freeze the independent watchdog.

The IWDG counts down from RLR at the LSI clock divided by the prescaler, and resets the chip at 0. Once started it cannot be stopped, except by a reset. The LSI is nominally 32 kHz but ranges from 17 to 47 kHz (DS10693), so allow for that when choosing a timeout: here about 100 ms nominal, 69-190 ms worst case.

iwdgFreezeInDebug(DBGMCU); // a breakpoint must not reset the chip
for (;;) { ...; iwdgRefresh(IWDG); }
#define DBGMCU
The DBGMCU instance.
Definition dbgmcu_reg.h:31
@ DRIVER_STATUS_OK
Succeeded.
DRIVER_MUST_CHECK DriverStatus_e iwdgStart(IwdgRegisters_t *iwdg, uint32_t prescaler, uint32_t reload)
Start the watchdog, then set its prescaler and reload value.
Definition iwdg.c:42
void iwdgFreezeInDebug(DbgmcuRegisters_t *dbgmcu)
Stop the IWDG counter whenever the core is halted by a debugger.
Definition iwdg.c:83
void iwdgRefresh(IwdgRegisters_t *iwdg)
Reload the counter from RLR (KR = 0xAAAA).
Definition iwdg.c:78
#define IWDG_PR_DIV32
LSI / 32.
Definition iwdg_reg.h:55
#define IWDG
The IWDG instance.
Definition iwdg_reg.h:33

After a reset, rccResetFlags() reports whether the IWDG caused it.

Definition in file iwdg.h.