STC15W408AS library 0.9.0
|
watchdog timer | |
Watchdog timer functions | |
#define | wdt_init(wdt_scale) |
Init WDT. More... | |
#define | wdt_start() (bit_set(WDT_CONTR, SBIT5)) |
Start WDT. More... | |
#define | wdt_stop() (bit_clr(WDT_CONTR, CBIT5)) |
Stop WDT. More... | |
#define | is_wdt_started() (test_if_bit_set(WDT_CONTR, SBIT5)) |
Get WDT start status. More... | |
#define | wdt_clear() (bit_set(WDT_CONTR, SBIT4)) |
clear WDT to prevent restart More... | |
#define | is_wdt_flag_on() (test_if_bit_set(WDT_CONTR, SBIT7)) |
Get reset by WDT flag. More... | |
#define | wdt_flag_reset() (bit_clr(WDT_CONTR, CBIT7)) |
Reset WDT flag. More... | |
#define | wdt_enable_in_idle() (bit_set(WDT_CONTR, SBIT3)) |
Enable WDT in MCU idle mode. More... | |
#define | wdt_disable_in_idle() (bit_clr(WDT_CONTR, CBIT3)) |
Disable WDT in MCU idle mode. More... | |
Functions and data structures related WDT
WDT - Watchdog timer is purposed for reset MCU on program hang up.
First step is init with scale. Scale determine WDT overflow time. Init WDT assume it not started. Separate wdt_start() / wdt_stop routines is used for explicitly start and stop WDT.
After wdt_start() call wdt_clear should be periodically called to restart WDT.
If wdt_clear() not called before WDT overflow MCU reset occurs.
If restart reason is WDT overflow then is_wdt_flag_on() return true. wdt_flag_reset() could be called to clear wdt_flag.
By default WDT is disabled in idle mode. wdt_enable_in_idle() change this.
WDT timings biased by MCU frequency change (frequency divider).
#define is_wdt_flag_on | ( | ) | (test_if_bit_set(WDT_CONTR, SBIT7)) |
Get reset by WDT flag.
WDT reset flag set after restart caused by WDT
#define is_wdt_started | ( | ) | (test_if_bit_set(WDT_CONTR, SBIT5)) |
Get WDT start status.
Call is_wdt_started after wdt_init call
#define wdt_clear | ( | ) | (bit_set(WDT_CONTR, SBIT4)) |
clear WDT to prevent restart
Call wdt_clear after wdt_start call to prevent WDT reset MCU
#define wdt_disable_in_idle | ( | ) | (bit_clr(WDT_CONTR, CBIT3)) |
Disable WDT in MCU idle mode.
By default WDT in idle mode is disabled.
#define wdt_enable_in_idle | ( | ) | (bit_set(WDT_CONTR, SBIT3)) |
Enable WDT in MCU idle mode.
By default WDT in idle mode is disabled.
#define wdt_flag_reset | ( | ) | (bit_clr(WDT_CONTR, CBIT7)) |
Reset WDT flag.
Reset WDT flag to false.
#define wdt_init | ( | wdt_scale | ) |
Init WDT.
WDT overflow time = (12 * wdt_scale * 32768) / MainFosc
wdt_scale | uint8_t WDT timer scale in range 0..7 |
#define wdt_start | ( | ) | (bit_set(WDT_CONTR, SBIT5)) |
Start WDT.
Call wdt_start after wdt_init call
#define wdt_stop | ( | ) | (bit_clr(WDT_CONTR, CBIT5)) |
Stop WDT.
Call wdt_stop after wdt_init and wdt_start call