2003-10-29 07:29 PM
How to create unitialized variables
2011-05-17 02:35 AM
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. Aragorn2011-05-17 02:35 AM
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 ]2011-05-17 02:35 AM
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.2011-05-17 02:35 AM
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 ?
2011-05-17 02:35 AM
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.
2011-05-17 02:35 AM
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.