Code for Default EEPROM Values

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We know that ATMEL settings of AVR's EESAVE is such that every time we program AVR, its EEPROM data is erased. We can change this in Fuse Bits.

Question is How to write a code in Winavr to specify default values of EEPROM locations?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to declare initialized eeprom variables, and the compiler will generate .eep file, that you can program into the eeprom.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Suggest you familiarise yourself with \winavr\doc\avr-libc\* and specifically EEMEM that can be applied to a variable definition to locate it into the .eeprom section. An example that places 3 initial values in .eeprom is:

#include 
#include 

uint8_t EEMEM data[] = { 0x1F, 0x45, 0x33 };

If you then build with an Mfile generated Makefile you'll find a
.eep file generated that contains:

:030000001F453366
:00000001FF

This can programmed into the AVR (or loaded into the simulator) to initialise the EEPROM data.

Cliff