Maybe this is a simple question, but I just couldn't figure it out. Can someone tell me how to place a constant variable into the specific ROM area? I would like to be able to set a constant value at a particualr ROM area and use a pointer to get it whenever I need it. Cheers, Tang
I still dream of this construct:
const unsigned char code magicNum _at_ 0x8000 = 0xAA;
and why ever not?
Mark, your dream has become true in C251 v2.14 already. I use it to store the Revision code of the application. Franc
Impossible! How could that be? How could C251 get that feature before C51? C51 is probably used 10 to 1 over C251. Unfare! I declare a 10 yard penalty, repeat second down (Man it's great to have the XFL now. February can be so cold without football). - Mark
Here is how I do it: 1. I define the code version in the header file:
/*********************** FIRMWARE CODE VERSION *****************************/ #define CODE_VERSION 3 // 10 is version 1.0
unsigned char code version _at_ 0x0006 = CODE_VERSION;
That's what I thought. I'm still dreaming of this feature for the C51. - Mark
Why does Keil have this restriction? You can do this with Raisonance and I would like to have my code be compatible with both. For Raisonance you just use: at 0x803d code char my_char = 0x55; I don't need to have a variable name created, but I would like to be able to set a byte that configures the hardware. This is a hardware configuration byte that needs to be programmed when the program is loaded. If I understand correctly there is no way to add a single statement to the Keil C program for this function. I have to link an assembly language file to do that with Keil. Is that correct?
"Why does Keil have this restriction?" Although it seems a simple enough addition apparently it will involve a major rewrite of part of the compiler. You can put the 'variable' in its own 'C' source file then link that as a 'user segment'. There's an example in the knowledgebase somewhere.