Is it possible to save a variable in RAM and then make a watch dog reset and then read back the same value from the RAM?
Or does the RAM get cleared?
I need to save a state machine state before the reset and then restore the state after power up.
I'm coding in C.
Didn't find your answer? Ask the community — no account required.
V
Vladimir Vassilevsky
I haven't seen any information about the persistence of the data in the internal RAM trough the hardware or watchdog reset. I wouldn't rely on that.
The C startup clears RAM unless you declare your data in the appropriate NO_INIT section.
The sophisticated algorithm will be required to distinguish the valid data from the arbitrary garbage at the initial start.
You don't want to do that.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
formatting link
D
dalai lamah
Un bel giorno Bubbah digitò:
I'm almost sure of that (only some registers in the register file are set/reset by soft/hard reset), but the best way to know is to try. Remember not to put your variables in an initialized section or obviously the loader will set them automatically when the program restarts. For example you can use an uninitialized global variable.
emboliaschizoide.splinder.com
B
Bubbah
I'm going to try it out. I will save a 16 byte value to get better certainty. If I only save an 8 bit value it is harder to know if it is my value or some garbage (as Vladimir pointed out).
T
TheDoc
registers are reset but ram is undefined.. it's nasty, but you can place data in an uninitialized section.. declare your "object data" as a structure for ease and run a CRC on the data block for integrity.... i would suggest a better method using an extant non volatile memory device tho..
V
Vladimir Vassilevsky
Saving persistent data to internal RAM is a bad idea.
There is absolutely no guarantee that it will work. And even if it works for now, it may stop working with the next CPU revision.
There is a zillion of possible reasons for the internal RAM to be completely or partially corrupt at reset, and you don't have any control about it. Thus if it is not explicitly guaranteed that RAM survives through the reset, you shouldn't rely on that.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
formatting link
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.