The XLINK linker has a segment type called XDATA which is used for AVR to specify EEPROM memory space.
To put data into EEPROM memory use the __eeprom keyword before the variable. Example:
__eeprom char strHello[] = "Hello World";
will put the array strHello into the EEPROM_I segment.
__no_init __eeprom char chVal;
will put the array chVal into the EEPROM_N segment.
Both these constructions will cause the code to be located in EEPROM memory (i.e. segments of XDATA type).
To write code in assembler that puts data into EEPROM we must be sure to place the data into a segment of type XDATA. To do this write:
RSEG MY_EEPROM_SEG:XDATA(0) strHello: DB "Hello World"
We can also add a code segment in the same assembler file, for example:
RSEG MY_EEPROM_SEG:XDATA(0) strHello: DB "Hello World" RSEG CODE:CODE(0) NOP END
And still be able to program both EEPROM memory and flash memory.
When linking a file contaning data that should be put into
EEPROM memory make sure to map the segment containing
this data into XLINK XDATA memory space. For the example written
in assembler above you should pass the parameter
-Z(XDATA)MY_EEPROM_SEG=0-7F to XLINK, where
0 is the beginning of
the segment in EEPROM memory and
7F
is the end. You can also safely add
-w29
to the XLINK command line to tell XLINK to ignore warning 29. To be able to program the chip you must make sure that
you can extract the EEPROM data into one separate file (see below).
Therefore use the
-FSimple
option to let the XLINK output be readable to the IAR Postlink utility.
Example:
xlink.exe -FSimple -ca90 -Z(XDATA)MY_EEPROM_SEG=0-7F -w29 my_file.r90
Gives the output in aout.raw in simple format.
To extract the EEPROM data into one file type:
postlink -intel-extended -xdata aout.raw > aout_eeprom.hex
Then use the aout_eeprom.hex file to program the chip EEPROM memory. See also postlink.htm for more information about the IAR Postlink utility.
Copyright 2001 IAR Systems. All rights reserved.