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.
Can anybody tell me how constants are stored in a 8051 application. If it is prom- able to write it to the PROM and how it will be accessed during program execution? thanks. regards, san
The following constant table:
const unsigned char code tens [] = { 1, 10, 100, 1000, 10000, 100000 };
Note that excluding the 'code' keyword will put it in RAM:
// Goes in RAM, not ROM. const unsigned char tens[] = { 1, 10, 100, 1000, 10000, 100000 }; // Goes in ROM const unsigned char code tens[] = { 1, 10, 100, 1000, 10000, 100000 };
Just to pick a nit however, note that in all of the previous examples, "char" should be changed to "long" to achieve the results implied by the array's initializers. --Dan Henry
Hehehehehe You are right! :-)
Hi Mark, thank you so much. in this case, // Goes in RAM, not ROM. const unsigned char tens[] = { 1, 10, 100, 1000, 10000, 100000 }; where tens will be stored? Whether in Heap? or in Stack? or some where globally? regards, san
// Goes in RAM, not ROM. const unsigned char tens[] = { 1, 10, 100, 1000, 10000, 100000 };
const unsigned char code tens[] = { ... };
static const unsigned char code tens[] = { ... };
Good grief, no wonder he's having problems! I didn't even notice this obvious bug. - Mark