cancel
Showing results for 
Search instead for 
Did you mean: 

keep ram value when NVIC_SystemReset();

dongocduy
Associate
Posted on May 13, 2016 at 05:20

i want to use watchdog to reset system when mcu loop, but after using NVIC_SystemReset(), all ram values are init again, i want to keep ram values same before SystemReset,

how do that????

4 REPLIES 4
knielsen
Associate II
Posted on May 13, 2016 at 14:31

I think the SRAM content should be preserved by a watchdog reset, though I did not find the precise spot in the docs that state this explicitly.

But your startup code probably clears and re-initialises your ram just after reset, unless you specifically rewrote it not to. You need to modify the startup code to check if the reset cause is watchdog, and in this case skip memory clear/initialisation and instead take the actions appropriate for your application.

Radosław
Senior II
Posted on May 13, 2016 at 14:52

>>I think the SRAM content should be preserved by a watchdog reset, though I did not find the precise spot in the docs that state this explicitly.

It is preserved, but at startup all variable are initialized.  This is C standard.

Put variables that you wonna preserved in separated section. How to do this depends on compiler that you use.

Posted on May 13, 2016 at 15:50

At ResetHandler all your data will be there, put structures into a NOINIT section/segment. The C runtime initializes the statics ie __main or _cstartup, or assembler loops in startup.s

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dongocduy
Associate
Posted on May 16, 2016 at 03:30

thanks for all; I done that;

I use __no_init __root before  variables ( ex: __no_init __root uint8_t tx[10]; )

variables will not init again if I reset system. they keep values before reset.