Hi, Is there any way to initialize EEPROM data except during running time ? Regards, Andre
Yes, the EEPROM area is programmable using a device programmer just like the program memory is.
Is it possible using C code and Keil initialize EEPROM data using such as : EEPROM data_type variable = initial_value If not, how can I do it ? Thanks, Andre
Hmm, directly from C code? I suppose that depends a bit on what your programmer needs in order to program the EEPROM area. I wrote my own serial programming utility and a separate compiler of sorts that generates EEPROM HEX files in the 0x2000-0x27FF range where the EEPROM is mapped during programming, so I never put any kind of "EEPROM initializers" in my actual C code. Off the top of my head, I suppose I'd try something like defining initialized data objects qualified with "const" and "code" they would get allocated to program memory, then coerce the linker to locate that particular code segment within the EEPROM address range. Don't bother thinking about using the _at_ keyword for initialized data objects. It won't work and has been discussed here frequently.
The latest examples included with the C51 installation show how to use the XDATA banking capabilities to enable you to locate 'C' variables in serial EEPROM. See also http://www.keil.com/forum/docs/thread1754.asp Having implemented that support, I don't see why you shouldn't then be able to use normal 'C' initialisers with those variables. However, note that the compiler would still have to store the initialisers in the CODE space (ROM) and would copy them into the EEPROM each time your application (re)booted. This doesn't sound like an appropriate approach for EEPROM - using a device programmer, or a special programming/initialisation mode sounds much more sensible. You could probably incorporate it as part of your unit's final test?