2.1.3.3 DIAG_WDT_Startup()

void DIAG_WDT_Startup (void )

Checks that the WDT is able to issue a timely system reset and that the WDT counter can be reset at start-up.

This diagnostic is intended to be executed at start-up, before entering the main function, as it involves multiple device resets. The diagnostic supports both the scenario where the WDT is enabled (and so locked) through the fuse bit and when it is not. In the former scenario, the diagnostic execution time will depend on the time-out period chosen for the WDT, while in the latter scenario, the WDT is enabled with the shortest WDT time-out period and disabled upon exiting the diagnostic.

This diagnostic function assumes global interrupts are disabled.

For AVR_EB processors, Timer/Counter E (TCE) is used to verify the timing of the WDT clock source since the TCE clock source is independent. For all other processors, Timer/Counter A (TCA) is used. The timer is set up and teared down as part of running the diagnostic. It is assumed that the timer resource is free at start-up before entering main.

The diagnostic has the following execution flow:
  1. A system reset occurs.

  2. Back up the RSTFR register and clear it.

  3. Enable the WDT (or reset counter if enabled through fuse).

  4. Measure the time it takes for the WDT to issue a system reset.

  5. Re-enter the diagnostic and check that the system reset occurred.

  6. Check that the system reset did not occur too soon or too late (with tolerance).

  7. Check that the WDT counter can be cleared without causing a reset.

  8. Wait for a WDT system reset to ensure that the counter clear worked correctly.

  9. Re-enter the diagnostic and store the result of the diagnostic.

  10. Tear down the timer used for measurement and exit to main function.

  11. DIAG_WDT_GetResult() must be called from main to get the result of the diagnostic.

Attention:

This diagnostic clears all Reset flags in the RSTFR register. Use the DIAG_WDT_GetRSTFRCopy() API to retrieve the copy of the register at start-up to handle unexpected resets in the application.

Parameters:
None.
Returns:

None.