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
  • Hello Everybody
    I figured the problem and resolved it

    The Hex file generated by compiler was not sequencial i.e 0x0000 is not at the begining
    same may be the case with other Addreses

    The programer i was using to burn the chip was not able to programe this type of hex file, i changes the programer and everything worked fine.

    Thanks for your replies.

Reply
  • Hello Everybody
    I figured the problem and resolved it

    The Hex file generated by compiler was not sequencial i.e 0x0000 is not at the begining
    same may be the case with other Addreses

    The programer i was using to burn the chip was not able to programe this type of hex file, i changes the programer and everything worked fine.

    Thanks for your replies.

Children