[Top][All Lists]

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

Re: [avr-gcc-list] AVRGCC initialisation of variables

From: Bruce D. Lightner
Subject: Re: [avr-gcc-list] AVRGCC initialisation of variables
Date: Mon, 23 Jul 2001 10:31:44 -0700


> Does anyone have a gracefull method of avoiding AVRGCC cleaning out variables 
> @ reset ?
> I want to retain the value of my Realtime Clock variables when the part 
> resets.

I'm not sure this is "graceful", but it has a lot fewer steps than my last
suggestion. You only have to add a couple of lines to your C-code.  For

 #define RTCvars _end             /* give "_end" an alternate name */
    extern unsigned char *_end;   /* point to SRAM *after* the .bss */
    unsigned char i;

    i = RTCvars[3];  // access uninitialized SRAM

This makes use of the fact that, by convention, the GNU AVR linker adds a
label called "_end" to mark the very end of the SRAM used by the linker. 
You can use this space as "uninitialized data" (i.e., from the label "_end"
to the end of your SRAM, minus what you use for stack space).  (It is a bit
of a "kludge", but will work! :-)
Best regards,


 Bruce D. Lightner
 Lightner Engineering (http://www.picoweb.net/)
 La Jolla, California
 Email: address@hidden
 URL: http://www.lightner.net/lightner/bruce/

reply via email to

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