cancel
Showing results for 
Search instead for 
Did you mean: 

Startup code variable initialization

kareemkna
Associate II
Posted on December 06, 2015 at 11:57

Hello

using MDK-ARM , I want from startup code change the initialization of global variable after warm reset (Pressing reset button) ... But I dont know where to look ?

The idea is I want the variable keep its value after warm reset, not re-initialized by zero.

Any Idea ?

#startup-code
2 REPLIES 2
Posted on December 06, 2015 at 18:34

Well it does cause a lot of complications. May be you need to think carefully about what you're doing, and how to do it? Doing it for everything has a lot of ramifications.

You could presumably make a ''noinit'' section within the scatter file, and place specific variables into that?

You could perhaps have that area be the NVRAM memory? Or a separate area of SRAM.

You could also group all of the state you want to hold across reset into a singular structure, and place that structure, or a pointer for it, in the NVRAM/NOINIT, and tag it in a way you can tell if it is valid or not.

The code in __main, which is called before your main() function deals with the initialization of statics, either by copying or zeroing.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kareemkna
Associate II
Posted on December 07, 2015 at 10:28

[Solved]

Thanks clive

noninit section worked, thanks a lot,  it was just a school exercise ,,, :)