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

Parents
  • "The Hex file generated by compiler was not sequencial"

    This is perfectly valid - there is nothing that says Intel Hex files must (or even should) be sequential!

    "The programer i was using to burn the chip was not able to programe this type of hex file"

    This is, unfortunately, a common fault of poorly-implemented tools.
    If they can't get something as basic as this right, you should be wondering what else they've messed up...

Reply
  • "The Hex file generated by compiler was not sequencial"

    This is perfectly valid - there is nothing that says Intel Hex files must (or even should) be sequential!

    "The programer i was using to burn the chip was not able to programe this type of hex file"

    This is, unfortunately, a common fault of poorly-implemented tools.
    If they can't get something as basic as this right, you should be wondering what else they've messed up...

Children
No data