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

Have a trouble in Delay programming...

Hello frnz,
i've designed a delay code that is as follows...
for(i=0;i<40000;i++);
The code has been designed for a NXP 89V51RD2 microcontroller similar to 8051 with a clock 11.0592MHz. How much delay could this line possibly generate?.. Time for single instruction is 1.085us. For 40000 counts, it may give upto 40 to 50 milliseconds. But in the development board the same code gives me nearly 0.7 to 1 second delay. Help me out please....

Parents
  • i've designed a delay code

    No, you haven't. At the non-existent level of understanding your target hardware that you demonstrate by asking those questions, you couldn't have. It's not design when you throw code together without actually knowing how it'll work.

    The code has been designed

    I'll take that to mean you didn't even write it; you just found it somewhere.

    Not that whoever you took it from did much designing to begin with. That snippet is exactly the naive, first idea everybody has about how to do a delay. And like many naive ideas in technical design, it's just plain dumb wrong more than 95 percent of the time.

Reply
  • i've designed a delay code

    No, you haven't. At the non-existent level of understanding your target hardware that you demonstrate by asking those questions, you couldn't have. It's not design when you throw code together without actually knowing how it'll work.

    The code has been designed

    I'll take that to mean you didn't even write it; you just found it somewhere.

    Not that whoever you took it from did much designing to begin with. That snippet is exactly the naive, first idea everybody has about how to do a delay. And like many naive ideas in technical design, it's just plain dumb wrong more than 95 percent of the time.

Children
No data