I need to store variables in nonvolitile memory using the 8051. I previously thought that this was impossible and my goal could only be accomplished through the use of an external EEPROM device; however, I have been told that it may be possible to use XDATA Banking to put 'C' variables in the EEPROM. Is this true? and if so, how do I go about doing it? Suggestions are greatly appreciated.
That could only work if you have EEPROM that can be written to by ordinary MOVX instructions. I'm quite sure that this is far from being the typical case.
Look in the c51\examples\FarMemory directory for "EEPROM on ...". The examples explain how to "map" a memory space and use special routines to handle access.
You could re-implement all the routines in the XBANKING / L51_BANK assembler files so that they did the correct EEPROM dance to get the memory device to accept the writes. (Also, the new routines must do the right thing for conventional xdata, if you have any, based on address.) The rest of the generated code uses these library routines for far access, so it would all "just work" at that point. But that's not as simple as the usual case of just mapping an address byte.
"That could only work if you have EEPROM that can be written to by ordinary MOVX instructions." No, that's not true. I have it on reliable authority (Jon Ward said) that the C51's so-called "XDATA-banking" support can be used to do this: http://www.8052.com/forum/read.phtml?id=24473 I've never done it myself, so the OP will just have to follow Dan's advice and look-up the examples... See also: http://www.keil.com/support/docs/2103.htm
Thanks for your feedback.