To get full control, you might find it easier to make a struct type
containing all your battery ram variables. Declare a ram variable of the
struct type, with an __attribute__ to ensure it is not in the bss or data
section (so that it does not get zapped on power-up), and declare a const
struct with the default values. You can then copy accross all the values as
and when needed, using a single assignement.
> Hello, All !
>
> I have a ittle problem and hope you can help me.
>
> I have several variables that resides in RAM and I use a battery to store
> the RAM content.
>
> How I should declare them to prevent startup initialization ?
> At this moment I use:
> int __attribute__((section(".xxxx"))) var;
> It work, but I am not sure that it is right :).
>
> Time to time (for example when battery fails) I need to initialize all (or
> some) of those variables
> with default values. Suppose I have the next code:
>
> int a=1; //this should be initialized every time the reset occures
> int x=10; //this should not be initialized when reset occures - only when
I
> need it
> int b=2; //this should be initialized every time the reset occures
> int y=20; //this should not be initialized when reset occures - only when
I
> need it
>
> By default all those variable will be put to the .bss segment, and initial
> values will be stored
> in the flash and copied at startup to the RAM.
>
> I need to group some of the variables to the different segment, that
behaves
> like .bss (but
> values are copied not at startup, but when I need). If I will do it I will
> be able to quickly
> initialize them (as _reset_Vector does), but only when I need to do it :).
>
> If you have any suggestions I would be very grateful to you.
>
> Do not think that I can just write x=10 :) when I need to initialize x , I
> have >1K of variables having different
> types defined in different files, so it is not acceptable.
>
> Thanks, Oleg.
> P.S. My thoughts could be unclear, so feel free to ask me :).
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>