Hi, i read somewhere that:
- as variables are assigned fixed locations at compile time;
- having battery-backed RAM;
-since Dynamic C doesn't implicitly initialize any variables (unlike most C compilers that zero static variables)
It follows that all global and local static variables in Dynamic C programs are non-volatile. Once a value is assigned to a variable, this value is retained (until it is assigned another).
I tried with an example (i'm not talking about xalloc, root2xmem etc): used an uninitialized
global var i, whose starting value makes three leds blinking in a certain sequence . (suppose
1->2->3->1, circularly)
Suppose that after a power-off/power-on they start blinking this way: 2->3->1->2->3->1.
Stopping things now, powering down and up, I expected the new sequence to be: 2->3->1...
But it was another one.I made several attempts.
WHATEVER was the last led blinking before i powered off, at power up leds always started to blink in the SAME sequence, starting from the same led.
I considered (via tcp-ip) the starting value of i, and in all cases it was the same, as if i was initialized (but 16384 is a strange value to be initialized to for an unsigned int ).
So, the only way to make vars to retain their values accross power up is is xalloc, root2xmem etc... ? those things i read misunderstood ?