Xmega IEC60730 Class B Library  1.0
 All Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wdt/UserApplication.c File Reference

Detailed Description

This is the demo application for the watchdog timer (WDT) test.

The self-diagnostic routine for the WDT is executed before the main function is called. If the WDT is not working properly, the device will hang.

This demo application sets up an interrupt for SW0, switches an LED on and then stays in a loop as long as the system is on a working state. In this loop the WDT is reset according to its open and closed period settings. If the error flag should be set, the main program would exit the loop and switch off the LED.

The following procedure can be followed in order to test that the correct behavior of the WDT. When button SW0 is pressed, the WDT is reset too early and it will issue a system reset. When button SW1 is pressed, the WDT is reset too late and a system reset will be issued as well. This "unexpected" resets should be caught by the self-diagnostic routine, which in this demo is configured to set the error flag, setup the WDT and continue to the main application. Therefore, after pressing any of the buttons the system is set on a safe state.

Application note:
AVR1610: Guide to IEC60730 Class B compliance with XMEGA
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@a.nosp@m.tmel.nosp@m..com

Copyright (C) 2012 Atmel Corporation. All rights reserved.

Definition in file wdt/UserApplication.c.

#include "avr_compiler.h"
#include "util/delay.h"
+ Include dependency graph for wdt/UserApplication.c:

Go to the source code of this file.

Functions

void setup_led_switches ()
 Hardware setup function for button- and LED functionality.
void correct_timing ()
 This delay is longer than the closed window setting, but shorter than the total period.
void fast_timing ()
 This delay is shorter than the closed window setting.
void slow_timing ()
 This delay is longer than the total period.
 ISR (SWITCH0_INT0_vect)
 Button SW0 interrupt function. The WDT will be updated too early.
 ISR (SWITCH1_INT0_vect)
 Button SW1 interrupt function. The WDT will be updated too late.

Variables

NO_INIT volatile uint8_t classb_error
 Global error flag.
void(* our_delay )(void) = &correct_timing
 This is a function pointer, initialized to the correct delay.