Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Watchdog Timer (WDT)

See Quick start guide for WDT driver.

This is a driver for configuring, enabling, disabling and use of the on-chip WDT.

Dependencies

The WDT module depends on the following modules:

Modules

 
 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the Watchdog Timer (WDT).
 

Macros

#define wdt_reset()   __asm__ __volatile__("wdr");
 This macro resets (clears/refreshes) the Watchdog Timer. More...
 

Enumerations

enum  wdt_timeout_period_t {
  WDT_TIMEOUT_PERIOD_8CLK = (0x00),
  WDT_TIMEOUT_PERIOD_16CLK = (0x01),
  WDT_TIMEOUT_PERIOD_32CLK = (0x02),
  WDT_TIMEOUT_PERIOD_64CLK = (0x03),
  WDT_TIMEOUT_PERIOD_125CLK = (0x04),
  WDT_TIMEOUT_PERIOD_250CLK = (0x05),
  WDT_TIMEOUT_PERIOD_500CLK = (0x06),
  WDT_TIMEOUT_PERIOD_1KCLK = (0x07),
  WDT_TIMEOUT_PERIOD_2KCLK = (0x08),
  WDT_TIMEOUT_PERIOD_4KCLK = (0x09),
  WDT_TIMEOUT_PERIOD_8KCLK = (0x0A)
}
 Watchdog timeout period setting. More...
 
enum  wdt_window_period_t {
  WDT_WINDOW_PERIOD_8CLK = (0x00),
  WDT_WINDOW_PERIOD_16CLK = (0x01),
  WDT_WINDOW_PERIOD_32CLK = (0x02),
  WDT_WINDOW_PERIOD_64CLK = (0x03),
  WDT_WINDOW_PERIOD_125CLK = (0x04),
  WDT_WINDOW_PERIOD_250CLK = (0x05),
  WDT_WINDOW_PERIOD_500CLK = (0x06),
  WDT_WINDOW_PERIOD_1KCLK = (0x07),
  WDT_WINDOW_PERIOD_2KCLK = (0x08),
  WDT_WINDOW_PERIOD_4KCLK = (0x09),
  WDT_WINDOW_PERIOD_8KCLK = (0x0A)
}
 Watchdog window period setting. More...
 

Functions

void wdt_disable (void)
 Disable Watchdog. More...
 
bool wdt_disable_window_mode (void)
 Disable Watchdog window mode without changing period settings. More...
 
void wdt_enable (void)
 Enable Watchdog. More...
 
bool wdt_enable_window_mode (void)
 Enable Watchdog window mode. More...
 
static enum wdt_timeout_period_t wdt_get_timeout_period (void)
 Gets the Watchdog timeout period. More...
 
static enum wdt_window_period_t wdt_get_window_period (void)
 Gets the Watchdog window period. More...
 
static bool wdt_is_enabled (void)
 Check if the Watchdog Enable flag is set. More...
 
void wdt_reset_mcu (void)
 Reset MCU via Watchdog. More...
 
void wdt_set_timeout_period (enum wdt_timeout_period_t to_period)
 Set Watchdog timeout period. More...
 
bool wdt_set_window_period (enum wdt_window_period_t win_period)
 Set Watchdog window period. More...
 
static void wdt_wait_while_busy (void)
 Wait until WD settings are synchronized to the WD clock domain. More...
 
static bool wdt_window_mode_is_enabled (void)
 Check if the Watchdog Window mode flag is set. More...
 

#define wdt_reset ( )    __asm__ __volatile__("wdr");

This macro resets (clears/refreshes) the Watchdog Timer.

Referenced by main(), and wdt_reset_mcu().

Watchdog timeout period setting.

Enumerator
WDT_TIMEOUT_PERIOD_8CLK 

Timeout period = 8 cycles or 8 ms @ 3.3V.

WDT_TIMEOUT_PERIOD_16CLK 

Timeout period = 16 cycles or 16 ms @ 3.3V.

WDT_TIMEOUT_PERIOD_32CLK 

Timeout period = 32 cycles or 32m s @ 3.3V.

WDT_TIMEOUT_PERIOD_64CLK 

Timeout period = 64 cycles or 64ms @ 3.3V.

WDT_TIMEOUT_PERIOD_125CLK 

Timeout period = 125 cycles or 125ms @ 3.3V.

WDT_TIMEOUT_PERIOD_250CLK 

250 cycles or 250ms @ 3.3V)

WDT_TIMEOUT_PERIOD_500CLK 

Timeout period = 500 cycles or 500ms @ 3.3V.

WDT_TIMEOUT_PERIOD_1KCLK 

Timeout period =1K cycles or 1s @ 3.3V.

WDT_TIMEOUT_PERIOD_2KCLK 

Timeout period = 2K cycles or 2s @ 3.3V.

WDT_TIMEOUT_PERIOD_4KCLK 

Timeout period = 4K cycles or 4s @ 3.3V.

WDT_TIMEOUT_PERIOD_8KCLK 

Timeout period = 8K cycles or 8s @ 3.3V.

Watchdog window period setting.

Enumerator
WDT_WINDOW_PERIOD_8CLK 

Window period = 8 cycles or 8 ms @ 3.3V.

WDT_WINDOW_PERIOD_16CLK 

Window period = 16 cycles or 16 ms @ 3.3V.

WDT_WINDOW_PERIOD_32CLK 

Window period = 32 cycles or 32m s @ 3.3V.

WDT_WINDOW_PERIOD_64CLK 

Window period = 64 cycles or 64ms @ 3.3V.

WDT_WINDOW_PERIOD_125CLK 

Window period = 125 cycles or 125ms @ 3.3V.

WDT_WINDOW_PERIOD_250CLK 

250 cycles or 250ms @ 3.3V)

WDT_WINDOW_PERIOD_500CLK 

Window period = 500 cycles or 500ms @ 3.3V.

WDT_WINDOW_PERIOD_1KCLK 

Window period =1K cycles or 1s @ 3.3V.

WDT_WINDOW_PERIOD_2KCLK 

Window period = 2K cycles or 2s @ 3.3V.

WDT_WINDOW_PERIOD_4KCLK 

Window period = 4K cycles or 4s @ 3.3V.

WDT_WINDOW_PERIOD_8KCLK 

Window period = 8K cycles or 8s @ 3.3V.

void wdt_disable ( void  )

Disable Watchdog.

This function disables the WDT without changing period settings.

The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. Disable functions operate asynchronously with immediate effect.

References ccp_write_io(), and temp.

Referenced by lowpower_init(), main(), and test_sha204_wakeup().

bool wdt_disable_window_mode ( void  )

Disable Watchdog window mode without changing period settings.

This function disables the WDT window mode without changing period settings.

The function writes the correct signature to the Configuration Change Protection register before writing the WINCTRL register. Interrupts are automatically ignored during the change enable period. Disable functions operate asynchronously with immediate effect.

Return values
trueThe WDT was enabled and the window mode is disabled. false The WDT (& the window mode) is already disabled.

References ccp_write_io(), temp, and wdt_is_enabled().

void wdt_enable ( void  )

Enable Watchdog.

This function enables the WDT without changing period settings.

The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the WDT to be synchronized to the WDT clock domain before proceeding

References ccp_write_io(), temp, and wdt_wait_while_busy().

Referenced by main(), and test_sha204_wakeup().

bool wdt_enable_window_mode ( void  )

Enable Watchdog window mode.

This function enables the WDT window mode without changing period settings.

The function writes the correct signature to the Configuration Change Protection register before writing the WINCTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the WDT to be synchronized to the WDT clock domain before proceeding

Return values
trueThe WDT was enabled and the setting is done. false The WDT is disabled and the setting is discarded.

References ccp_write_io(), temp, wdt_is_enabled(), and wdt_wait_while_busy().

Referenced by main().

static enum wdt_timeout_period_t wdt_get_timeout_period ( void  )
inlinestatic

Gets the Watchdog timeout period.

This function reads the value of the WDT timeout period.

Return values
TheWDT timeout period.

Referenced by main().

static enum wdt_window_period_t wdt_get_window_period ( void  )
inlinestatic

Gets the Watchdog window period.

This function reads the value of the WDT closed window coded period.

Return values
TheWDT window period.
static bool wdt_is_enabled ( void  )
inlinestatic

Check if the Watchdog Enable flag is set.

Return values
falseWDT disabled true WDT enabled

Referenced by wdt_disable_window_mode(), wdt_enable_window_mode(), and wdt_set_window_period().

void wdt_reset_mcu ( void  )

Reset MCU via Watchdog.

This function generates an hardware microcontroller reset using the WDT.

The function loads enables the WDT in window mode. Executing a "wdr" asm instruction when the windows is closed, provides a quick mcu reset.

References ccp_write_io(), temp, wdt_reset, and wdt_wait_while_busy().

Referenced by main().

void wdt_set_timeout_period ( enum wdt_timeout_period_t  to_period)

Set Watchdog timeout period.

This function sets the coded field of the WDT timeout period.

The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the WDT to be synchronized to the WDT clock domain before proceeding

Parameters
to_periodWDT timeout coded period

References ccp_write_io(), temp, and wdt_wait_while_busy().

Referenced by main(), and test_sha204_wakeup().

bool wdt_set_window_period ( enum wdt_window_period_t  win_period)

Set Watchdog window period.

This function sets the coded field of the WDT closed window period. Note that this setting is available only if the WDT is enabled (hardware behaviour relayed by software).

The function writes the correct signature to the Configuration Change Protection register before writing the WINCTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the WDT to be synchronized to the WDT clock domain before proceeding

Parameters
win_periodWindow coded period
Return values
trueThe WDT was enabled and the setting is done. false The WDT is disabled and the setting is discarded.

References ccp_write_io(), temp, wdt_is_enabled(), and wdt_wait_while_busy().

Referenced by main().

static void wdt_wait_while_busy ( void  )
inlinestatic

Wait until WD settings are synchronized to the WD clock domain.

Referenced by wdt_enable(), wdt_enable_window_mode(), wdt_reset_mcu(), wdt_set_timeout_period(), and wdt_set_window_period().

static bool wdt_window_mode_is_enabled ( void  )
inlinestatic

Check if the Watchdog Window mode flag is set.

Return values
falseWDT Window disabled true WDT Window enabled