Dear All,
I write a function with Local Static Variable. But can't get its value initiated.
void analyzeInputs() { static uByte TimeState = 0; // Init Value switch (TimeState) { case 0 : TimeState++; // MORE CODE HERE ... break; case 1 : TimeState++; // MORE CODE HERE ... break; case 2 : TimeState = 0; // MORE CODE HERE ... break; } }
When go to debug mode, at first, it always jump to Case 1 (not 0), mean : no value initiated.
But if I change, declare "TimeState" as Global Var then its value init fine.
-> Is it because the Keil won't init any static local variable during Start-Up Code ?
<quote>Note that this doesn't just apply when the codes are identical</quote>
undoubtebly.
u can learn some simple optimisation words here
http://www.keil.com/support/man/docs/c51/c51_ap_opt_general.htm
Always yo're freind.
Zeusti.
(putting supercomputer power into ur sporrans)