Hello, Some of the variables that my program uses(may contain also big ,multidimensional arrays) have default values, which are used during the code operations and may be modified during the program's runtime. defining a variables using:
volatile xdata arrayName = [0x01, 0x03, 0x02, 0x04...];
volatile code arrayName = [0x01, 0x03, 0x02, 0x04...];
No, there is no such method. Because there can't be. Initializers have to be in read-only code memory so you can load them into the device as part of the program, where they will survive a power-cycle of the device. But modifiable variables must be in RAM. Thus, an initialized modifiable variable must exist in two separate copies. Nothing to be done about it. There's one possible way around this, though: computed startup values. I.e. you can do the initialization manually, instead of leaving it to the compiler, and express it in a more compact manner than a list of values. If you're lucky.
"Initializers have to be in read-only code memory ... where they will survive a power-cycle of the device." They don't absolutely have to be in CODE space. If you have non-volatile memory in XDATA space, then it can be done. Search for XCONST for details. You may need special tools to be able to write the initial values into the non-volatile XDATA area... Even with non-volatile XDATA, if you want the initial values restored on reset, you will still need to save the reset values somewhere, and have some code to copy them to the working area.
XCONST wouldn't help him --- he wants these objects to be runtime-modifiable. The ultimate catch here is that what he's trying to do can't be expressed in C. A C variable is either initialized (at compile/link time, putting the initializer in CODE and the variable in XDATA), or it's not (then there's no way to specify an initializer at all). This means the initializers would have to be generated by some other means. A separately compiled & linked assembly project filling a XCONST segment at the relevant address could work. Meaning that boot-loader would have to load two hex-files into different address spaces (unless those 64K are von-Neumann).
View all questions in Keil forum