[−][src]Module nucleo_f042k6::watchdog
API for the IWDG
You can activate the watchdog by calling start
or the setting appropriate
device option bit when programming.
After activating the watchdog, you'll have to regularly feed
the watchdog.
If more time than timeout
has gone by since the last feed
, your
microcontroller will be reset.
This is useful if you fear that your program may get stuck. In that case it won't feed the watchdog anymore, the watchdog will reset the microcontroller and thus your program will function again.
Attention:
The IWDG runs on a separate 40kHz low-accuracy clock (30kHz-60kHz). You may want to some buffer in your interval.
Per default the iwdg continues to run even when you stopped execution of code via a debugger. You may want to disable the watchdog when the cpu is stopped
let dbgmcu = p.DBGMCU; dbgmcu.apb1_fz.modify(|_, w| w.dbg_iwdg_stop().set_bit());
Example
use stm32f0xx_hal as hal; use crate::hal::stm32; use crate::hal::prelude::*; use crate::hal:watchdog::Watchdog; use crate::hal:time::Hertz; let mut p = stm32::Peripherals::take().unwrap(); let mut iwdg = Watchdog::new(p.iwdg); iwdg.start(Hertz(100)); loop {} // Whoops, got stuck, the watchdog issues a reset after 10 ms iwdg.feed();
Structs
IwdgTimeout | Timeout configuration for the IWDG |
Watchdog | Watchdog instance |