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1, 0x2, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x2, 0x2, 0x2, 0x0, 0x1, 0x3, 0x3, 0x2, 0x0, 0x3, 0x0, 0x0, 0x0, 0x2, 0x2, 0x1, 0x1, 0x3, 0x3, 0x3, 0x0, 0x1, 0x0, 0x2, 0x3, 0x0, 0x3, 0x3, 0x0, 0x1, 0x1, 0x2, 0x3, 0x3, 0x3, 0x0, 0x2, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x2, 0x2, 0x0, 0x3, 0x3, 0x3, 0x2, 0x2, 0x3, 0x3, 0x2, 0x2, 0x2, 0x2, 0x1, 0x2, 0x3, 0x2, 0x3, 0x1, 0x1, 0x2, 0x0, 0x2, 0x0, 0x2, 0x1, 0x2, 0x0, 0x0, 0x0, 0x2, 0x2, 0x1, 0x1, 0x2, 0x0, 0x3, 0x0, 0x0, 0x2, 0x3, 0x2, 0x1, 0x1, 0x3, 0x3}
But when I compile the code with this array, I get some warnings from compiler:
memory overlap near 0x500 for CABSb
memory overlap near 0x520 for CABSb
memory overlap near 0x540 for CABSb
memory overlap near 0x560 for CABSb
memory overlap near 0x600 for CABSb
memory overlap near 0x620 for CABSb
memory overlap near 0x640 for CABSb
What does this means or better how can I bypass these warnings?
[ Edited Tue Jan 06 2015, 02:59 pm ]
Its good that you figured out. In embedded C try to avoid using __at__ unless you know how your code relocation is going to be done via linker.ajay_bhargav
Can you be more specific on what you said about code realocation via linker????
OK.. linker decides where to keep your code sections. If in your code you explicitly place rodata section then linker tries to place that section on a particular location and if there is another code section which belongs to same location then you will get this error. So either you need to change address of rodata you defined or you need to look into the scatter file (linker for keil) to look what section goes where and then define the right address.ajay_bhargav
OK, I got it... I'm using SDCC to compile my code. I have looked into my memory map file and noticed that I have declared an unsigned short right next to an unsigned char, so the unsigned short was overlapping the unsigned char. That's why that error message was coming up!
Thanks
Psy
[ Edited Mon Jan 12 2015, 01:31 pm ]
OK, I got it... I'm using SDCC to compile my code. I have looked into my memory map file and noticed that I have declared an unsigned short right next to an unsigned char, so the unsigned short was overlapping the unsigned char. That's why that error message was coming up!
Thanks
PsyPsySc0rpi0n
The compiler should take care of allocating memory.
If it doesn't, it's a useful thing to know.
OK, I got it... I'm using SDCC to compile my code. I have looked into my memory map file and noticed that I have declared an unsigned short right next to an unsigned char, so the unsigned short was overlapping the unsigned char. That's why that error message was coming up!
Thanks
PsyPsySc0rpi0n
The compiler should take care of allocating memory.
If it doesn't, it's a useful thing to know.ExperimenterUK
Yes it does, indeed. But I have allocated those variables into specific memory locations like:
__data __at (0x10) unsigned short var1; __data __at (0x11) unsigned char var2;
So, because a short int takes 2 bytes, it would be using 0x10 and 0x11 and therefore, overlapping var2 at 0x11.
[ Edited Wed Jan 14 2015, 03:57 pm ]