 RE: Value get changed in function arrgument (fixed memory location)
yogesh sharma
Dear Per Westermark,
i analyzied your reply, please find my query in embedded with your
reply.
But that is not a problem with the C51 compiler, but with how it is used.
accpect, i may not be aware of it, but want to be!
It is well documented that C51 converts auto variables and parameters into
global variables shared memory locations with other auto variables and parameters
based on the call tree analysis.
if possible provide me document links,also i want to see call tree,
is this possible?
So ISR:s shouldn't call same functions as main loop does.
in my case function is only called in ISR, not in ground loop.
see my interrupt
static void XFER (void) interrupt 13 //one sec and one min interrupt metrology
{
int a=0x00;
gucOneMinuteCount++;
fTimeinSec();// changed 20/apr/2012
in this interrupt function is fTimeinSec();//
please see function
void fTimeinSec()
{
uint32x_t lRTsec,ltemp;
const int lDaysInMonth[12]={0,31,59,90,120,151,181,212,243,273,304,334};
.
.
.
.
}
now what complier did, it assigned same fixed memory location to
varialbles
used in function fTimeinSec() and some of the ground loop function
arguments.
ofcourse this may due to function fTimeinSec() is not dependent on
any function.
but interrupt can be occure any time (that is why it is interrupt).
call tree found
interrupt function and ground loop function is independent while it
is not. then it courrupt locations.
now it looks clearly, call tree analysis not done properly.
interrupt variable and arrguments should consider for call tree
dependancy.
And code should specifically mark functions that needs to be reentrant - or
code rewritten to not make sure of recursive designs.
neither i am using reentrant nor i m using recursive designs.
The important thing here is that the 8051 chip just isn't designed for use
with a traditional stack for parameters and local variables.
it would be your great help if you make understand what is limitation
of traditional stack for parameters and local variables.
thanks,
|