This is the demo application for the CPU frequency test.
The test basically checks periodically that the relationship between the RTC and CPU frequencies (measured through a Timer/Counter, TC) is within a configurable range.
The main program consists of a loop where the device does not do anything as long as there is no error in the CPU frequency. An LED is on while the system is operating correctly. However, if the error flag should be set, the main program would exit the loop and switch off the LED.
In order to test that the self-diagnostic routine is correct, the CPU frequency can be modified on-the-fly by pressing the button SW0. By default the system runs from the internal 2 Mhz oscillator. The interrupt for button press changes the system clock to the internal 32 Mhz oscillator. The CPU frequency test will then fail because the frequency of the system does not match the configuration.
Copyright (C) 2012 Atmel Corporation. All rights reserved.
Definition in file frequency/UserApplication.c.
Include dependency graph for frequency/UserApplication.c:Go to the source code of this file.
Functions | |
| void | setup_led_switches () |
| This function sets up the LED and switch. The LED is switched on to show that the system is working correctly. The switch is configured to generate an interrupt after being pressed. | |
| ISR (PORTE_INT0_vect) | |
| Interrupt service routine for button press. This will change the clock frequency to 32MHz, which should be detected by the frequency test. | |
Variables | |
| NO_INIT volatile uint8_t | classb_error |
| This is the error flag. | |