Watchdog Timer with interval timer capabilities.
More...
Watchdog Timer with interval timer capabilities.
Module Operation
MSP432 includes a standard watchdog module that is identical to the WDT_A module of MSP430. By using DriverLib, the user can configure all aspects of the watchdog peripheral including using the watchdog in interval mode as well as watchdog mode.
Watchdog Mode
Once the module is initiated in watchdog mode, the timer will reset part if the count expires. The reset can be set as either a soft or hard reset. This use case is useful when the programmer wants to make sure that the code execution isn't perpetually stuck/locked in an unrecoverable state.
To configure the WDT module in watchdog mode, the WDT_initWatchdogTimer function is used such as follows:
This will set the watchdog timer to be sourced from SMCLK and have a duration of 512,000 SMCLK cycles. This means that once started, if the watchdog timer goes 512,000 iterations without being reset a reset will occur. To reset the counter (after using WDT_startTimer to start the timer), the user should use the WDT_resetTimer function.
Interval Mode
MSP432 Driverlib can also configure the WDT module to work in interval mode. This turns the WDT into an ordinary 16-bit down counter with interrupt support. This can be used if the user needs access to another low power counter, however has already used other resources. To configure the module in interval mode, use the WDT_initIntervalTimer function such as follows:
This will configure the WDT module to be sourced from SMCLK and have a period of 32,000 cycles. In this example, we have previously configured SMCLK to be 64Khz making this timer's period be approximately half a second. After using the WDT_startTimer function to start the timer, the user can service interrupts from interval mode after enabling interrupts using the Interrupt_enableInterrupt function.
Setting Reset Type
The type of reset that occurs on watchdog timeout/password violation can be configured through the SysCtl module using the SysCtl_setWDTPasswordViolationResetType and SysCtl_setWDTTimeoutResetType APIs. These APIs will allow the user to change whether a soft or hard reset occurs on a watchdog timeout and password violation. For the user, the convenience functions WDT_setPasswordViolationReset and WDT_setTimeoutReset exist in the WDT APIs.
Programming Examples
The DriverLib package contains a variety of different code examples that demonstrate the usage of the WDT module. These code examples are accessible under the examples/ folder of the SDK release as well as through TI Resource Explorer if using Code Composer Studio. These code examples provide a comprehensive list of use cases as well as practical applications involving each module.
Below is a very brief code example showing how to configure the WDT module in interval mode:
#define WDT_A_CLOCKSOURCE_SMCLK (WDT_A_CTL_SSEL_0) |
#define WDT_A_CLOCKSOURCE_ACLK (WDT_A_CTL_SSEL_1) |
#define WDT_A_CLOCKSOURCE_VLOCLK (WDT_A_CTL_SSEL_2) |
#define WDT_A_CLOCKSOURCE_BCLK (WDT_A_CTL_SSEL_3) |
#define WDT_A_CLOCKDIVIDER_2G (WDT_A_CTL_IS_0) |
#define WDT_A_CLOCKDIVIDER_128M (WDT_A_CTL_IS_1) |
#define WDT_A_CLOCKDIVIDER_8192K (WDT_A_CTL_IS_2) |
#define WDT_A_CLOCKDIVIDER_512K (WDT_A_CTL_IS_3) |
#define WDT_A_CLOCKDIVIDER_32K (WDT_A_CTL_IS_4) |
#define WDT_A_CLOCKDIVIDER_8192 (WDT_A_CTL_IS_5) |
#define WDT_A_CLOCKDIVIDER_512 (WDT_A_CTL_IS_6) |
#define WDT_A_CLOCKDIVIDER_64 (WDT_A_CTL_IS_7) |
void WDT_A_holdTimer |
( |
void |
| ) |
|
Holds the Watchdog Timer.
This function stops the watchdog timer from running. This way no interrupt or PUC is asserted.
- Returns
- None
Referenced by PCM_gotoLPM4().
void WDT_A_startTimer |
( |
void |
| ) |
|
Starts the Watchdog Timer.
This function starts the watchdog timer functionality to start counting.
- Returns
- None
void WDT_A_clearTimer |
( |
void |
| ) |
|
Clears the timer counter of the Watchdog Timer.
This function clears the watchdog timer count to 0x0000h. This function is used to "service the dog" when operating in watchdog mode.
- Returns
- None
void WDT_A_initWatchdogTimer |
( |
uint_fast8_t |
clockSelect, |
|
|
uint_fast8_t |
clockDivider |
|
) |
| |
Sets the clock source for the Watchdog Timer in watchdog mode.
- Parameters
-
clockSelect | is the clock source that the watchdog timer will use. Valid values are
- WDT_A_CLOCKSOURCE_SMCLK [Default]
- WDT_A_CLOCKSOURCE_ACLK
- WDT_A_CLOCKSOURCE_VLOCLK
- WDT_A_CLOCKSOURCE_BCLK
|
clockIterations | is the number of clock iterations for a watchdog timeout. Valid values are
- WDT_A_CLOCKITERATIONS_2G [Default]
- WDT_A_CLOCKITERATIONS_128M
- WDT_A_CLOCKITERATIONS_8192K
- WDT_A_CLOCKITERATIONS_512K
- WDT_A_CLOCKITERATIONS_32K
- WDT_A_CLOCKITERATIONS_8192
- WDT_A_CLOCKITERATIONS_512
- WDT_A_CLOCKITERATIONS_64
|
This function sets the watchdog timer in watchdog mode, which will cause a PUC when the timer overflows. When in the mode, a PUC can be avoided with a call to WDT_A_resetTimer() before the timer runs out.
- Returns
- None
void WDT_A_initIntervalTimer |
( |
uint_fast8_t |
clockSelect, |
|
|
uint_fast8_t |
clockDivider |
|
) |
| |
Sets the clock source for the Watchdog Timer in timer interval mode.
- Parameters
-
clockSelect | is the clock source that the watchdog timer will use. Valid values are
- WDT_A_CLOCKSOURCE_SMCLK [Default]
- WDT_A_CLOCKSOURCE_ACLK
- WDT_A_CLOCKSOURCE_VLOCLK
- WDT_A_CLOCKSOURCE_BCLK
|
clockIterations | is the number of clock iterations for a watchdog interval. Valid values are
- WDT_A_CLOCKITERATIONS_2G [Default]
- WDT_A_CLOCKITERATIONS_128M
- WDT_A_CLOCKITERATIONS_8192K
- WDT_A_CLOCKITERATIONS_512K
- WDT_A_CLOCKITERATIONS_32K
- WDT_A_CLOCKITERATIONS_8192
- WDT_A_CLOCKITERATIONS_512
- WDT_A_CLOCKITERATIONS_64
|
This function sets the watchdog timer as timer interval mode, which will assert an interrupt without causing a PUC.
- Returns
- None
void WDT_A_registerInterrupt |
( |
void(*)(void) |
intHandler | ) |
|
void WDT_A_unregisterInterrupt |
( |
void |
| ) |
|
void WDT_A_setPasswordViolationReset |
( |
uint_fast8_t |
resetType | ) |
|
void WDT_A_setTimeoutReset |
( |
uint_fast8_t |
resetType | ) |
|