SRAM after reset

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

Hi to all,

Should I expect any loss of SRAM stored data after reset (wdt, external reset) ?

I mean, after the reset I'll find the same values or should I assume there will be garbage data?

Thanks,
Marco / iw2nzm

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

Unless it's been a brown-out reset (:-), no, SRAM will keep its contents.
Obviously, for similar reasons, it will contain just random garbage after
a power-on reset.

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

Thank you. I'm very happy to hear this :)

Marco / iw2nzm

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

SRAM will keep its contents, but if the reset was caused by the WDT, who knows what has happened to the state of things? In this case I really would not bet on anything.

Jim

Your message here - reasonable rates.

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

Any "loss" of SRAM after a watchdog or external reset? No, as others have outlined.

Can you rely on every value being valid? Not really.

unsigned int i; // 16 bits
...
i++;
...

Is the value of i valid after a reset at an arbitrary time? Not always. Consider if i is 255, the increment is done, and only one half of the result gets stored when the reset occurs. i could have 0 instead of 256 (or depending on your compiler's code generation model, 511 instead of 256).

Since you can't assume anything after a powerdown or brownout reset anyway [don't forget to handle the case where your program runs away or otherwise ends up at the reset vector], it would be nice to know what situation you are really addressing.

If you are using C, without special "noinit" or similar global vars are going to have initial values anyway.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

So compute a checksum of the ram vars, store it in ram, inc a 'dirty' counter when you save a ram var, recompute the checksum if dirty, check checksum against stored value when warm starting from reset?

Imagecraft compiler user