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.
Hi Guys
How am i able to assign values to a variable i have stored in flash so that it is included in the hex file?
For example: i have declared a variable volatile unsigned char code err_msgs[10][20] _at_ FLASHSTART;
but cannot assign an initial value to it and have to write it's value to flash when my program starts.
Xarion
"how can i assign my 10 strings to this array?"
The code keyword has no effect on this - you do it the same way you would for any standard ANSI 'C' array with any standard ANSI 'C' compiler. Therefore, see any 'C' textbook.
"not exactly sure what volatile means"
volatile is a standard ANSI 'C' keyword - it has no special meaning in Keil C51. Therefore, again, see any 'C' textbook.
See also: http://www.keil.com/forum/docs/thread11735.asp
yeah i can just strcpy into the array at runtime but thats going to use more code to write each character to flash as to write to flash its not just assigning to a variable, i'm running tight with space which is my real aim in doing this.
"yeah i can just strcpy into the array at runtime"
No, you can not!
You not only need a 'C' textbook, but also an 8051 textbook!
As far as 'C' is concerned, you cannot write to a const object;
As far as the 8051 is concerned, you cannot write to CODE space.
You need to initialise the array in its definition - in the same way that you can initialise any other 'C' array in its definition...