IAR-Cannot place data in EEPROM

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

Hi there,

I don't know if this is the right forum for posting an IAR C compiler question, but I cannot see any other forum for posting.

My problem is that I cannot place data in an EEPROM absolute segment. My code is:
/* Data placement in EEPROM */
#define EEPROM_FAULTS 0x00
__eeprom const UC noFault @ EEPROM_FAULTS = 0x00;

while I can place data in FLASH using:
/* Data placement in FLASH*/
#define FLASH_FAULTS 0x1FF
__flash const UC noFault @ FLASH_FAULTS = 0x00;

I have read the IAR C Compiler manual and I think that I am doing it well.

When I inport the debug file in AVRStudio in order to debug it I cannot see the data in EEPROM, while I can see it in FLASH.

Why this happened???

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

May need to use the upload/download file function from debug.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

First of all I am sorry for posting the same question a couple of times. It was a mistake.

John,

I tried this, but nothing is happened. The debug file that IAR generates is named program.d90 (ubrof 8). For uploading an EEPROM file I need a program.eep. How can I generate an .eep file with only the eeprom initialized addresses???

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

That I'm stuck with as I haven't used the EEPROM with C of any description, just with ASM.
Someone will jump in with help for sure. :)

ps I have found this in the docs folder of IAR "Avr EEPROM howto.htm" May help.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Use the linker extra options to generate 2 files for FLASH AND EEPROM.

-Ointel-extended,(CODE)=flash.a90
-Ointel-extended,(XDATA)=eeprom.a90

Last Edited: Thu. Nov 28, 2013 - 12:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jens,

Can you give me some details of doing this, because it's seems a little bit difficult to get it.

Thanks a lot.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

To get correct output of EEPROM hex file:

- in linker options set output format to debug(ubrof)
- in linker extra options check 'use command line options' and type into the edit field:
-Ointel-standard,(CODE)=.code.hex
-Ointel-standard,(XDATA)=.eeprom.hex

This will produce a xxx.code.hex to program into flash and a xxx.eeprom.hex to program into the EEPROM.

Hope this helps,
Jörg.

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

icarus1I don't know if this is the right forum for posting an IAR C compiler question, but I cannot see any other forum for posting.[/quote wrote:
Michael, this is the correct forum for all AVR programming platforms except for avr-gcc.

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

icarus1 wrote:
I don't know if this is the right forum for posting an IAR C compiler question, but I cannot see any other forum for posting.
Michael, this is the correct forum for all AVR programming platforms except for avr-gcc.

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

Guys,

Thank you all.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Jörg,

I have followed your suggestions:

Quote:
To get correct output of EEPROM hex file:

- in linker options set output format to debug(ubrof)
- in linker extra options check 'use command line options' and type into the edit field:
-Ointel-standard,(CODE)=.code.hex
-Ointel-standard,(XDATA)=.eeprom.hex

Then I wrote those lines in my code:
__eeprom const unsigned char version[] @ 0xF0 = "v.1.00";
__eeprom const UC h @ EEPROM_HOURS = 0x00;
__eeprom const UC d15 @ EEPROM_DAYS_15 = 0x00;
__eeprom const UC d180 @ EEPROM_DAYS_180 = 0x00;
__eeprom const UC f @ EEPROM_FAULTS = 0x00;

and after compilation the final result inside the xxx.eeprom.hex is this:
:00000101FF
:00000001FF

which is not seem to be what I expect.

Please,

Where am I wrong???

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

I mostly use it in the following way:

#define _INPUTCONF      2000

#pragma location = _INPUTCONF
__root __eeprom U32 CInputConf = 0x00000000L;

Please look up the meaning of the _root keyword in your Compiler doc (I am a bit busy :-))

Jörg.

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

Jörg,

Very thanks for your very kind help. I wrote the word __root in front of my instructions and everything solved.

Maybe I have to read more about the compiler options.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

try...

#include 

__eeprom int i;
int tmp;

void main(void)
{
  i = 0xA7;     // write 0xA7 to EEPROM
  tmp = i;      // read from EEPROM into tmp
}

hope it'll help,
pak