cancel
Showing results for 
Search instead for 
Did you mean: 

How to create unitialized variables

giovanni239955
Associate II
Posted on October 30, 2003 at 04:29

How to create unitialized variables

6 REPLIES 6
giovanni239955
Associate II
Posted on May 17, 2011 at 11:35

Hi all!

I'm trying to define some char variables which MUST not be initialized to 0 at startup. THe micro I'm using is ST92F

Please can you help me, providing an example?

Many thanks in advance.

Aragorn

kapil
Associate II
Posted on May 17, 2011 at 11:35

If you just want the variable for not being equal to 0 at the time of

Startup, probably you can equate it to some other value at the time of startup e.g. unsigned int i = 10

[ This message was edited by: chaps on 21-10-2003 13:51 ]
kapil
Associate II
Posted on May 17, 2011 at 11:35

If you just want the variable for not being equal to 0 at the time of

Startup, probably you can equate it to some other value at the time of startup e.g. unsigned int i =10 or whatever.

romain2399
Associate II
Posted on May 17, 2011 at 11:35

I guess you want to keep the value as it was before the reset. So an intialisation to another value than zero is not what you want. Correct ?

ritu
Associate II
Posted on May 17, 2011 at 11:35

If I have understood you well , then you want to define a variable which does not lose its value on reset. To achieve this your variable should lie in .bss section (data Section for uninitialized data) which should be located in RAM (to be defined in linker (.ld) file). And by default any global variable which you don't initalize lies in .bss section. So as long as you are defining your .bss section to lie in RAM your uninitialized variable should not lose its value till you go for power off.

kapil
Associate II
Posted on May 17, 2011 at 11:35

Then you have to use eeprom area in memory to store that variable,

or always keep a copy of that variable value in eeprom and after the reset, the variable value to be restored from eeprom.