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,
I'm trying to locate a variable to an specific address. There are three ways to do this:
1) using options of the file that have the variable and config the RAM area 2) unsigned int cont __at (0x2000000); 3) #define cont (*((unsigned int *)(0x2000000)))
The first one, is too bad because is posible that I want to locate variables to diferents locations. The second one, is perfect for me, but when compiling the compiler generate a very big file from CODE area to RAM area even using a not init area. The third one, works perfect, but is not a standard way to do it.
How can I use __at tense without make a very big file?
My code are located at 0x1000000 and the data are at 0x2000000.
Thanks!!!
I have use style 3 on my projects. Why do you consider it not standard? Following is a line from a lpc project.
#define IOPIN0 (*((volatile unsigned long *)0xE0028000))
"#define IOPIN0 (*((volatile unsigned long *)0xE0028000))"
The trouble with this is that the tools do not know that you are using location 0xE0028000 - so there is nothing to stop them putting something else there...
Thank you!!
Ever all my projects use __at tense, is more easy to read, but now I like the third option because I can see that you use it. Thanks.
Finally I use this:
#define _at(x) (*((volatile unsigned int *)(x))) #define uchar_at(x) (*((unsigned char *)(x))) #define uint_at(x) (*((unsigned int *)(x))) #define ulong_at(x) (*((unsigned long *)(x))) #define char_at(x) (*((char *)(x))) #define int_at(x) (*((int *)(x))) #define long_at(x) (*((long *)(x)))
There are not "volatile", because is not a register and ever the compiler knows when it change.
Thanks!!
But see my previous warning:
"The trouble with this is that the tools do not know that you are using the pointed-to locations - so there is nothing to stop them putting something else there..."
Thats is clear, but, there are any other method to do this with the supervision of the compiler?. Using __at directive the results are not good.