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.
I am using an 8051 (C51/BL51) with no off-chip memory. I have two functions with parameters:
void Detect( U8 iLed )
and
static U8 INHSampleHandler( U16 u16Sample )
Now I understand that Keil will allocate a variable (in DATA) for these. The problem seems to be that the locator is using the same memory location for both. I cannot understand why.
Below are excerpts from the scratchpad showing 2 "D:0026H". These are the only places these symbols are declared. Any ideas what I'm doing wrong?
Thanks, Jeff
BL51 BANKED LINKER/LOCATER V5.12 07/14/2011 09:36:23 PAGE 1 BL51 BANKED LINKER/LOCATER V5.12, INVOKED BY: Z:\TOOLS\SOFTWARE\KEIL\BL51.EXE Z:\Software\FB_CPU_Init.obj, >> Z:\Software\Settings.obj, Z:\Software\Glo >> bals.obj, Z:\Software\Devices\Clock.obj, Z:\ >> Software\Devices\Flash.obj, Z:\Software\Devices\HMI.obj >> , Z:\Software\Devices\INH.obj, Z:\ >> Software\Devices\ADC.obj, Z:\Software\Devices\Timer.obj, Z >> :\Software\Builds\TestINH - 06-00039-21-09\Main.obj >> , Z:\Software\Test\Test_Button.obj, Z:\So >> ftware\Builds\TestINH - 06-00039-21-09\Version.obj TO Z:\ >> Software\Builds\TestINH - 06-00039-21-09\06-00039-21-09-xx.wsp >> RS (256) PL (68) PW (78) XDATA (?XD?SETTINGS (0X0)) CODE (?CO?VERSION (0X7 >> FC0)) MEMORY MODEL: SMALL Deleted for brevity ------- PROC _INHSAMPLEHANDLER D:0026H SYMBOL u16Sample C:0BF1H LINE# 150 C:0BF5H LINE# 151 C:0BF5H LINE# 207 C:0BF7H LINE# 208 ------- ENDPROC _INHSAMPLEHANDLER ------- ENDMOD INH Deleted for brevity C:09FEH PUBLIC _Detect C:074EH PUBLIC main ------- PROC _DETECT D:0026H SYMBOL iLed
"I think I've demonstrated the problem here"
I am not as confident.
I have tried to replicate your code, using a timer isr instead of your adc isr. Both variables are allocated at the same address.
and I never observed them having the same value.
so unless shown otherwise, I am going to agree with others that you are trying to solve a problem that doesn't exist.
No, I don't think that you have demonstrated it here.
That may or may not mean that there is no problem - it might just be because the example presented here is over-simplified so that the problem doesn't arise.
Probably worth a discussion with Keil support - likely to be easier to share a more substantial example with them...
I've tried to make my example more "complicated" but that darn optimizer is too smart. On the other hand my actual code is more than one swallow. I'll see if I can work up an example that actually fails.
Make sure your functions make use of the parameter, and have them write the parameter value to a volatile variable. Volatile variables are normally a good way to get the optimizer to stop removing code - you want to convince the compiler that there is an important side effect that must not be optimized away.
I've tried to make my example more "complicated" but that darn optimizer is too smart
try optimize = 2. this is basically variable overlay and nothing else.
to the homewrecker and the sardine: please not the word basically
Erik
"please not the word basically"
is it too much to ask that you write complete and comprehensible sentences, erik?
"I'll see if I can work up an example that actually fails."
I have one that follows your basic structure but uses a tmr isr to trigger one of the subroutines.
as andrew pointed out, you need to make sure that both subroutines actually operate on those two variables.
Folks, I think you are gallantly galloped way, way off the beaten path if the original poster is posting summary's like "A helpful post"
I love a good name calling and the pedantic arguments session, but maybe it would be better to create a new thread next time we want to do this? I do not think it was benefiting the OP.
Scratch that, I bet we can get this done without the name calling, especially the dreaded "s" word (sardine).