[an error occurred while processing this directive] [an error occurred while processing this directive]
Ответ:
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено Abat 10 марта 2002 г. 18:41
В ответ на: использование ключевого слова __eeprom в IAR C++ отправлено Андрей Светлов 10 марта 2002 г. 17:20

How to put data into EEPROM memory using the XLINK XDATA segment type
Updated: 06/Jul/2001 [IOLW]
Archived: $Revision: 1.3 $
Background
The XLINK linker has a segment type called XDATA which is used for AVR to specify EEPROM memory space.

Write code in C that puts the data into EEPROM
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).

Write code in assembler that puts data into EEPROM
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.

Linking EEPROM data
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.

Use IAR Postlink utility to get EEPROM data in separate file
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.

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru