We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have never used external RAM before (beleive it or not :-o ) . Now I am using an NVRAM from Dallas so that in case of power failure the value of some variables is retained. My question is how do I declare the 'Non Volatile External' variable and how do I retreive the previous (pre-power fail) value ?
Suppose I declare an XDATA variable in my program , would it be automatically intialised as zero , for example :
int XDATA non_vol _at_0x0010; //variable at 0010h . . . if(some_event_occured) { non_vol++; //increment var on some event }
Review this thread: http://www.keil.com/forum/msgpage.asp?MsgID=4719 BTW: note that the Keil C51 xdata keyword is lowercase, and you need a space between the _at_ and the address value. (just typos in your post?) BTW2: note that applying bold seems to defeat the <pre> and </pre> tags - the font is no longer monospaced :-(
Memory is not initialised by the compiler. You must explicitly initialise it. If you use the startup code, you can set it up to clear any memory area you want. Also, unless you MUST specify addresses for RAM, why not let the linker decide where in memory to put variables? This is much easier on the developer as well as avoiding conflicts between modules.
If I just declare a variable it would not be initialised ba default ?
"If I just declare a variable it would not be initialised ba default?" The compiler doesn't know how much XRAM you have, nor its base address. Therefore, if you want your XRAM to be initialised, you must specify its size and base address - you do this by means of the startup code Of course, this gives you the opportunity to specify that some areas of XRAM will be initialised, while others (eg, NVRAM) will not. For details, refer to the thread cited earlier: http://www.keil.com/forum/msgpage.asp?MsgID=4719
Hello, you must declare a static variable (of course without any initialisation). Automatic variables (all variables you "just declare" are automatic) don't survive even leaving the block they was declared in, so how should they survive power off? Have success - Peter