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
this is a copy of my posting today. If I follow the recommendation of the compiler manual, the linker puts the table of pointers into xdata. I must use the non-preferred method (per the utilities manual). Thanks. By the way, I can't find the pdf for the utilites manual. Is there one? === paste === User's guide, 01.97, C compiler C51 on page 63 'explicitly defined memory types' recommends a syntax. The Utilities guide, 04.95, page 119, has a different syntax in files c_mess0.c, c_mess1.c. the utilities guide contradicts the recommendation in the user's guide. Yet the 'preferred' method in the C51 compiler will NOT work. You must use the 'obsolete' method of the Utilities guide. (1) Please explain. (2) What is correct syntax for: const unsigned char code *MyArray[NumberFruits] = {"apple,"banana","cherry"};
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.
const unsigned char code *MyArray[NumberFruits] = {"apple,"banana","cherry"}; There's one occurrence of "code" in this definition, to the left of the *. That means it applies to the "unsigned char". So, this is a table of pointers (in RAM) that point to characters in code memory. If you want the pointers themselves in code memory, you need to specify that as well:
const unsigned char code* code MyArray...