This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The "place a value at a specific address" problem

Hi all,

I just read the posts "variable" regarding the problem to position a value (or variable) at a specific address. These posts were related to C51, that's why I start a new thread here, to find out if there is a "good" solution for this with C166.

It might be that I didn't get the whole problem, but using C51 the solution for this was as easy as:

char xdata test _at_ 0x12345
That places the variable test exactly at 0x12345 and my problem is solved (works fine in my application).

Switching from C51 to C166, the _at_ command was gone, for some reason, and no way to place a variable at a specific address.

Solution:
1) Place only the variable you need in a separate file and link the file at a specific address. Works, but if you need "many" variables, that doesn't seem practical anymore... I guess the length of the linker command line has it's limitations at some point.

2) use a macro like this:
#define test MVAR (char, 0x12345)
This replaces every occurance of "test" with a memory access at the address 0x12345, which is also exactly what we want to do. But again, it doesn't seem to be the "final" solution, because since it is not really a declaration of a variable, the used memory address(es) is not protected from any other access. There is no variable placed at this spot, so any other variable "could" be placed there overwriting the one I need. So, I have to make sure that the memory area where I place my variables is protected.

Isn't there any other way to do this with C166? It was so easy with C51 and the _at_.

Thanks for any advice/help
Holger

0