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

how to make loop (1sec) using djnc ,mov and nop only.

hi
i am jimmy and my problem is very simple but complicated. how to make a loop subroutine for 1 sec +500 microsec or -500 microsec by just using djnc, mov and nop.
it is a 8051 problem so kindly help me.

  • "it is a 8051 problem"

    So why have you chosen C251 as the product??

    Presumably this is your homework, so you are supposed to come up with the answer yourself?
    But here's a hint: you need to know two things:

    1). Your processor's clock frequency;

    2). How many clock cycles (and, hence, how long) it takes to execute the djnc, mov and nop instructions on the particular variant you are using.

    Knowing those two things, you should be able to see how you can use them together to make your required delay...

  • As pointed out, you need a relationship between real time ( say 500us ) and the system clock period. Another hint is that your problem has two time values in it so you may need to use an instruction twice to generate them. It's a nice exercise in instruction set properties but get familiar with the timers and interrupts for real world applications. :)