|
|
View previous topic :: View next topic |
Author |
Message |
hundil Guest
|
global variables |
Posted: Thu Jun 10, 2004 8:29 am |
|
|
My Question is very short;
In CCS, Global variables are to be considered as =0 in the beginning,
Or assigned to be any value.
If so, what is the fonction of zero_ram command
thanks for repliers
hundil |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Jun 10, 2004 9:49 am |
|
|
I have never assumed ANY variables are zero at start-up unless the chip datasheet says so. Ideally zero_ram would never be needed but with the inevitability of bugs it is possible for the CPU to read a ram location that was never written to, with unpredictable results. Using zero_ram fills all of memory with zero before boot. This can help mitigate "flakey" problems that are hard to eliminate. If your program requires zero_ram to work, it has a problem. Zero_ram doesn't fix problems, it just hides them. But sometime hiding a problem will get you through the day.... _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Ttelmah Guest
|
Re: global variables |
Posted: Thu Jun 10, 2004 10:12 am |
|
|
hundil wrote: | My Question is very short;
In CCS, Global variables are to be considered as =0 in the beginning,
Or assigned to be any value.
If so, what is the fonction of zero_ram command
thanks for repliers
hundil |
Zero_ram, ensures that _all_ variables (including non_global ones) will start at zero. Personally, it is quicker, and safer, to code your variale declarations to have the values you want, and only leave 'undeclared' variables that receive values as their first operation. However if you don't want to do this, zero_ram gives you a 'known' starting point, but at the cost of quite a long initialisation sequence. Note that the exact behaviour of variables, has changed slightly with compiler versions, and currently the manual only says that variables declared with the 'static' keyword are initialised to 0 by default. If you want to check how the compiler currently behaves, set up one simple variable of each type, and check what is actually done during initialisation.
best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|