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.
when I define a variable like next: uchar idata M_TVar _at_ 0x80; I got a warning: *** WARNING L4: DATA SPACE MEMORY OVERLAP FROM: 0000H TO: 0001H
the next is in .M51 file:
* * * * * * * D A T A M E M O R Y * * * * * * * IDATA 0000H 0001H ABSOLUTE * OVERLAP * IDATA 0000H 0001H ABSOLUTE * OVERLAP * REG 0000H 0008H ABSOLUTE "REG BANK 0" DATA 0008H 0040H UNIT ?DT?MAIN
how i fix it?
As you know. I want to store some of such variables into EEPORM, So, when I use absolute address, the R/W routine will be very simple. And my question is that, the address i used is 0x80, but the warning say it at 0000H. Why??
"As you know. I want to store some of such variables into EEPORM"
How is anyone supposed to know that? You didn't mention it!
"And my question is that, the address i used is 0x80"
So it is - I'm sorry, I misread that initially!
"but the warning say it at 0000H"
The warning says that the overlap is at 0000H - so there must be something else.
Are you sure you don't have any other absolutely-located items - whether using _at_ or Linker controls or whatever...
I can see someone at Keil coding 0x80 as IDATA 0 (sometimes I think of it that way), who knows.
Ask Keil support
Erik
I have resolved that problem
the error is in the define of variable in my head file: the old: #ifdef GLOBAL_VAR #define EXT_VR #else #define EXT_VR extern EXT_VR uchar idata M_TVar _at_ 0x80;
And I use the file in two files: fileA.c and fileB.c
and the newest file writen as: #ifdef GLOBAL_VAR #define EXT_VR EXT_VR uchar idata M_TVar _at_ 0x80; #else #define EXT_VR extern EXT_VR uchar idata M_TVar;// _at_ 0x80; So it works good. but I don't know why. may be Keil just do it in that way;
thanks for every body!!
by the way, must define GLOBAL_VAR once before include headfile in one of C files.
"but I don't know why"
The _at_ is only meaningful on a definition - not in a declaration
ie, _at_ doesn't make sense with extern!
You need something like
#ifdef DEFINE_GLOBAL // Make a definition #define EXT_ABS(name,loc) uchar idata name _at_ loc #else // Make an extern declaration #define EXT_ABS(name,loc) extern uchar idata name #else EXT_ABS( M_TVar, 0x80 );
#ifdef GLOBAL_VAR #define EXT_VR #else #define EXT_VR extern
I suggest you do yourself a favour and get rid of this supposed "trick". It may seem like a major advantage to only have to write declarations once, but
1) it only works for a subset of globals --- if you have an explicit initializer, you have to write the definition and declaration separately again.
2) it puts stuff into the interface (header) that shouldn't be there: the initializers.
3) it shoves all globals of the entire program into one translation unit (which has to include all header files, too). That can make it needlessly hard for the linker to fit all those variable into memory, especially if memory space is fragmented.