Discussion in "Project Help" started by    PsySc0rpi0n    Nov 27, 2014.
Fri Dec 12 2014, 10:07 pm
#21
Does that method of reading timers works if I use mode 2 (256 counts max, auto-reload)????
Tue Dec 16 2014, 10:14 am
#22
Well Mode 2 is only 8-bit so its even simpler, max value will be 255.
unsigned char time;
time = TL1; /* Timer value */
Tue Jan 06 2015, 02:58 pm
#23
I have generated an array of 500 random numbers in C and then I have copied that array into my 8051 C code.

__code __at (0x0500) array = {
0x3, 0x0, 0x3, 0x3, 0x3, 0x0, 0x1, 0x0, 0x2, 0x1, 0x3, 0x2, 0x0, 0x3, 0x2, 0x0, 0x1, 0x0, 0x1, 0x3, 
0x1, 0x1, 0x0, 0x2, 0x3, 0x3, 0x1, 0x2, 0x2, 0x1, 0x2, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x2, 0x1, 0x0, 
0x3, 0x0, 0x2, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x2, 0x3, 0x0, 0x1, 0x2, 0x0, 0x2, 0x1, 0x2, 
0x3, 0x3, 0x0, 0x0, 0x1, 0x1, 0x1, 0x2, 0x3, 0x2, 0x2, 0x2, 0x2, 0x1, 0x2, 0x1, 0x1, 0x3, 0x2, 0x2, 
0x0, 0x2, 0x1, 0x3, 0x2, 0x2, 0x2, 0x2, 0x0, 0x3, 0x1, 0x3, 0x2, 0x1, 0x3, 0x3, 0x2, 0x0, 0x2, 0x1, 
0x2, 0x0, 0x3, 0x0, 0x1, 0x2, 0x2, 0x3, 0x1, 0x0, 0x1, 0x1, 0x2, 0x2, 0x1, 0x0, 0x0, 0x3, 0x3, 0x0, 
0x2, 0x0, 0x3, 0x0, 0x1, 0x3, 0x0, 0x3, 0x3, 0x2, 0x0, 0x2, 0x2, 0x3, 0x2, 0x0, 0x1, 0x0, 0x3, 0x2, 
0x0, 0x0, 0x0, 0x2, 0x3, 0x1, 0x3, 0x3, 0x0, 0x2, 0x0, 0x2, 0x2, 0x3, 0x2, 0x3, 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 0x3, 
0x0, 0x0, 0x1, 0x3, 0x1, 0x3, 0x1, 0x2, 0x0, 0x0, 0x3, 0x1, 0x3, 0x3, 0x2, 0x3, 0x0, 0x0, 0x1, 0x1, 
0x0, 0x0, 0x2, 0x3, 0x1, 0x2, 0x1, 0x1, 0x0, 0x2, 0x0, 0x1, 0x2, 0x1, 0x0, 0x3, 0x1, 0x2, 0x1, 0x1, 
0x2, 0x1, 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 ]
Tue Jan 06 2015, 04:03 pm
#24
I got it... No need to answer!!!
Fri Jan 09 2015, 10:19 am
#25
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.
Fri Jan 09 2015, 09:33 pm
#26


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????
Mon Jan 12 2015, 10:39 am
#27
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.
 PsySc0rpi0n like this.
Mon Jan 12 2015, 01:30 pm
#28


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 ]
Wed Jan 14 2015, 11:37 am
#29


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

PsySc0rpi0n


The compiler should take care of allocating memory.
If it doesn't, it's a useful thing to know.
Wed Jan 14 2015, 03:57 pm
#30



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

PsySc0rpi0n


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 ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am