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 ?
C51 does not have any "native" support for nonvolatile RAM that I'm aware of. Using a contrived example, let's say you have a single 32K nonvolatile RAM device, 8K of which you need for "volatile" data and 24K of which you need for nonvolatile data. You would configure STARTUP.A51 for only the 8K that would hold conventional volatile C/assembly xdata objects. This way the 8K gets cleared (and optionally initialized) as part of the C runtime startup. The remaining 24K is totally up to your software to manage. That is, you must explicitly clear it when you need to and explicitly place data objects there. This is the technique I have used. I suppose you could also consider using assembly language modules to allocate (and externalize) data to named nonvolatile segments and have the linker locate these segments. At least this way you could use C identifier names and the linker would resolve the addresses for you.