This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Calling Function more than once causing problem

I have develoved a small programe which toggels LED, In this programe i have make a function called delay() which i call more than once in my main programe, as shown

void main(){
while(1){
P1 = 0x00;
delay();
P1 = 0xFF;
delay();}
}

void delay(){
int i;
for(i=0;i<10000;i++);}

I compile it and run on simulator it worked as expected but when i programed it and try to run on my hardware it didnt

I am using AT89c51 micro from ATMEL

BUT if i replace the the function calling by it content every thing works well, like below

void main(){
int i;
while(1){
P1 = 0x00;
for(i=0;i<10000;i++);

P1 = 0xFF;
for(i=0;i<10000;i++);
}
}

can anybody help