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

Detailed Description

Demo application for the CRC tests.

This is an example that shows how the Flash and EEPROM CRC tests can be embedded in an user application. The CRC checksums of the Flash and a data section in EEPROM are pre-calculated and stored in EEPROM. During normal execution an LED is lighted while the system runs without errors. Pressing a button leads to CRC test of the Flash and the data section in EEPROM: new checksums are computed and compared with the ones stored in EEPROM. If any of the pairs were different, the error flag would be set (within the test) and the LED would be switched off. This can be tested for example by declaring the symbols MODIFY_FLASH and MODIFY_EEPROM.

Note that if the program is modified, the stored CRC needs to be computed again since the content in Flash will change. This can be done by debugging the program and placing a watch on the following variables:

  • checksum_test_flash
  • checksum_test_eeprom

Those values can be assigned then to

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 crc/UserApplication.c.

#include "avr_compiler.h"
#include "classb_crc.h"
+ Include dependency graph for crc/UserApplication.c:

Go to the source code of this file.

Macros

#define MODIFY_FLASH
 If declared the content of the flash is modified.
#define MODIFY_EEPROM
 If declared the content of the EEPROM data section is modified.

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 (SWITCH_INT0_vect)
 Interrupt service routine for button press.

Variables

uint32_t classb_precalculated_flash_crc = 0xe7138241
 This variable contains the CRC checksum for the flash and is stored in EEPROM.
uint16_t classb_precalculated_eeprom_crc = 0xcd4b
 This variable contains the CRC checksum for the data section in EEPROM. It is stored in EEPROM.
uint8_t data_eeprom [] = {0,1,2,3,4,5,6,7,8,9,10}
 Data stored in EEPROM.
NO_INIT volatile uint8_t classb_error
 Global error flag.

Macro Definition Documentation

#define MODIFY_FLASH

If declared the content of the flash is modified.

If declared an endless loop is compiled at the end of the main application. This changes the program code and thus the flash content. The previously stored checksum will then be different than the new one.

Definition at line 83 of file crc/UserApplication.c.

#define MODIFY_EEPROM

If declared the content of the EEPROM data section is modified.

If declared an endless loop is compiled at the end of the main application. This changes the program code and thus the flash content. The previously stored checksum will then be different than the new one.

Definition at line 94 of file crc/UserApplication.c.


Function Documentation

ISR ( SWITCH_INT0_vect  )

Interrupt service routine for button press.

This will compute the checksums of the Flash and data section in EEPROM and compare them with the ones stored in EEPROM. There some code lines that could be uncommented in order to check the other CRC implementations.

Definition at line 188 of file crc/UserApplication.c.

References CLASSB_CRC16_EEPROM_HW(), CLASSB_CRC32_Flash_HW(), classb_precalculated_eeprom_crc, classb_precalculated_flash_crc, CRC_APP, and data_eeprom.

+ Here is the call graph for this function: