This test checks that the watchdog timer (WDT) is working. The WDT is a system function for monitoring correct program operation that allows recovering from error situations such as runaway or deadlocked code. The self-diagnostic test classb_wdt_test() is executed before the main application and it basically makes sure that:
The test relies on the Real Time Counter (RTC) to check the timing of the WDT oscillator and, therefore, this library includes a basic RTC driver (see Real Time Counter Driver). Note that the RTC has a clock source independent from the CPU and the WDT. The RTC module is implicitly tested as well: if the frequency difference between RTC and WDT is more than 50%, the error state is set.
Errors are handled by CLASSB_ERROR_HANDLER_WDT() and there are two configurable actions:
In addition to error handler and configurable actions, the user should configure the WDT periods CLASSB_WDT_WPER and CLASSB_WDT_PER.
Configuration settings | |
| #define | CLASSB_WDT_WPER WDT_WPER_500CLK_gc |
| This is the closed period, where WDT cannot be reset. | |
| #define | CLASSB_WDT_PER WDT_PER_250CLK_gc |
| This is the open period, where WDT has to be reset. | |
Class B Test | |
| void | classb_wdt_test (void) |
| This is the watchdog timer (WDT) self-diagnostic test. | |
| #define CLASSB_WDT_WPER WDT_WPER_500CLK_gc |
This is the closed period, where WDT cannot be reset.
This should be given as one of the group configuration settings. The total timeout period is the sum of the open and closed periods. In order to comply with the standard, this should be at least 50% of the total period.
Definition at line 105 of file classb_wdt_test.h.
Referenced by classb_wdt_test().
| #define CLASSB_WDT_PER WDT_PER_250CLK_gc |
This is the open period, where WDT has to be reset.
This should be given as one of the group configuration settings. The total timeout period is the sum of the open and closed periods. In order to comply with the standard, this should be no greater than than 50% of the total period.
Definition at line 112 of file classb_wdt_test.h.
Referenced by classb_wdt_test().
| void classb_wdt_test | ( | void | ) |
This is the watchdog timer (WDT) self-diagnostic test.
Basically this functions tests the following:
The expected (error-free) execution flow is as follows:
The real time counter (RTC) is used as an independent clock source, which is used to check the timing of the oscillator used by the WDT.
The reset cause is used to decide which actions to take. The user can configure how to process a reset caused by the watchdog when the test is in the "ok" state, i.e. CLASSB_ACTIONS_WDT_RUNTIME_FAILURE(), or what to do for brown-out or software reset, i.e. CLASSB_ACTIONS_WDT_OTHER_FAILURE().
Definition at line 107 of file classb_wdt_test.c.
References CLASSB_ACTIONS_WDT_OTHER_FAILURE, CLASSB_ACTIONS_WDT_RUNTIME_FAILURE, classb_error, CLASSB_ERROR_HANDLER_WDT, CLASSB_WDT_PER, and CLASSB_WDT_WPER.