This application demonstrates the use of Atmel's certified Class B-test algorithms for XMEGA in a simulation of an induction oven on an XMEGA-A3BU Xplained board.For more information about class B compliance with XMEGA and the certified test code, please refer to the application note "AVR1610: Guide to IEC 60730
Class B Compliance with XMEGA".
- Note
- To operate this demo, it is necessary to mount jumpers between pins ADC2-ADC4 on header J2 and pins RXD-SS on header J1 of the XMEGA-A3BU Xplained.
- Note
- The Flash CRC test is commented out in oven_classb_run_tests() in oven_classb.c because the result depends on the compiled code, i.e., it is affected by changes in the toolchain and project settings. To use the test, a precalculated CRC must be retrieved by setting a breakpoint in the function after
checksum_test_flash
is assigned, and its content then copied into classb_precalculated_flash_crc
, which is stored in EEPROM. Recompile and reprogram the project, and the test will check against the correct value.
The application consists of several elements:
- The ASF framework: Used for device setup, graphical presentation and use of the Timer/Counter, ADC and DAC modules
- The Class B tests: The certified tests are distributed with the application note AVR1610
- The oven application consisting of
- main.c: The main function, with initialization and work loop.
- oven_plant.c: A simple discrete model of heat transfer between a plate, a pot with water and the environment
- oven_controller.c: Emulates the control logic of a real oven
- oven_ui.c: Controls the user interface, draws graphics, reads button states.
- oven_classb.c: Initialization and execution of Class B tests. Provides an error test-bench which can induce errors on the device to verify that the tests catch the errors they are designed to catch.
- oven.h: Application timer module selection and global constants. If the WDT periods are changed in classb_wdt.h, the watchdog reset period must be updated in this file to reflect the changes.
The Class B tests are set up at the start of the oven_application process, and are called by the oven controller when the user "turns on" the simulated oven by pressing SW1.
When power is turned on, indicated by a power bar, some tests are performed periodically.
How to operate the application
When running, the controller and simulation plant communicate through two interfaces, DAC to ADC to simulate a temperature sensor, and frequency generation and -capture to simulate the signal an induction cooker would send to the induction elements.
The control path is outlined below.
Using the application.
When the oven application is running, the display shows a continuously updated graph of the pot temperature (1) and plate temperature (2), together with an icon that indicates whether the pot is on or off the plate (3) and a bar that visualizes the applied power (4), as exemplified in this screen capture:
To turn on the power and cycle between the power levels, the user can press SW1 on the upper right hand of the evaluation board. To simulate that a pot is placed on the plate, the user can touch the QTouch button QTB0 on the lower left hand of the board.
Inducing errors in the application
By pressing the upper left key, marked SW0, the user enters a menu, allowing the user to choose an error to induce by pressing the Up/Down buttons and selecting with the QTouch button.
To recover from an induced error, the device must be reset. This can be done by cycling power on the board or resetting the device via debugger.
The entries in the error induction menu are:
- Change clock frequency: Changes the peripheral clock divider, simulating that the clock system has malfunctioned. This should be detected by the Class B frequency consistency test.
- Mess with test timer: Changes how often periodic tests are performed, simulating an error with an interrupt timer. This should be detected by the Class B interrupt monitor.
- Change a Flash section: Changes the string for the menu title stored in program memory to "Out of cheese", simulating Flash memory corruption. This can be changed back by selecting the menu item again. This should be detected by the Class B Flash CRC test, if it has been enabled.
- Scramble SRAM section: Starts a continuous DMA transfer in the background to a memory location, simulating transient SRAM corruption. This should be detected by the Class B SRAM test.
- Change ADC reference: Enables an interrupt that will change the ADC voltage reference after the first successful conversion. This will result in an unexpected ADC reading being caught in the Analog IO plausibility check which is run when the "oven" is turned on by pressing the SW1-button on the board.
- Enter infinite loop: Simulates a runaway program counter by looping forever. This should be detected by the watchdog timer system which is tested on device power-up.
Last, an error can be induced by removing the jumper between ADC2 and ADC4 on the J2 header on the XMEGA-A3BU Xplained board.