avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Eeprom section


From: Julius Luukko
Subject: Re: [avr-gcc-list] Eeprom section
Date: Tue, 24 Feb 2004 16:14:20 +0200
User-agent: KMail/1.4.3

On Tuesday 24 February 2004 16:02, Brian Cuthie wrote:
> Anyone know how I get something into the .eeprom section from C?  I'm
> guessing is some kind of __attribute__.
>
> While I realize that the EEPROM has to be read and written using special
> instructions, ideally I'd like the compiler to at least allocate the
> storage so that I don't have to manually keep track of what lives where.
> Also I'm assuming that I can use objcopy to extract the .eeprom section and
> pre-populate the EEPROM during the programming process.

Hello Brian and all,

An example: Define two variables in EEPROM with initial values 5 and 2:

#define EEPROM __attribute__((section(".eeprom")))

uint8_t eevari1 EEPROM=5;
uint8_t eevari2 EEPROM=2;

Then read these variables to RAM

uint8_t newvari1;
uint8_t newvari2;

newvari1=eeprom_read_byte(&eevari1);
newvari2=eeprom_read_byte(&eevari2);

My Makefile (from WinAVR) has the following to extract the .eeprom section 
from the elf file.

%.eep: %.elf
        -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
        --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
 

-- 
D.Sc. Julius Luukko
Laboratory of Control Engineering/Department of Electrical Engineering
Lappeenranta University of Technology, FINLAND
phone:+358-5-621 6713, fax:+358-5-621 6799, www: http://www.ee.lut.fi


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]