preserve SRAM contents during reset..

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

Hi there

Is there a way that I can specify that the compiler must NOT initialize SRAM variables after reset? I have some variables that get overwritten after a reset to wake up from sleepmode...

regards
Carel

www.pteq.net
Home of:
- Polygon Technologies CC

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

Let me refine my question:
How do I go about modifying the startup file?

I am using the Winavr distribution..

regards
Carel

www.pteq.net
Home of:
- Polygon Technologies CC

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

Please use the forum search, and search for ».noinit«.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

I actually DID search the forums, but I did not know to look for something like ".noinit". :?
Most of the stuff I got from my searches were replies saying: "please search the forum, this has been discussed before" :(

Anyways, I found the answer :lol: , and I share it here for any future would-be searchers. It is NOT neccesary to modify the startup file in order to prevent variables from being initialized (overwritten) during startup...

Any variable you do NOT want initialized on startup, you can declare as follows:

  __attribute__ ((section (".noinit")));

Example: 
unsigned int Myvar __attribute__ ((section (".noinit")));

Regards
Carel

www.pteq.net
Home of:
- Polygon Technologies CC