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
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
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.
Thank you. I'm very happy to hear this :)
Marco / iw2nzm
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
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
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?