find the time delay for the delay subroutine shown to the le
find the time delay for the delay subroutine shown to the left, if the system has an 8051 with frequency of 11.0592 MHz.
DELAY: MOV R5, #100
BACK: MOV R2, #200
AGAIN: MOV R3, #250
HERE: NOP
NOP
DJNZ R3, HERE
DJNZ R2, AGAIN
DJNZ R5, BACK
RET
Solution
For the 11.0592Mhz 8051 1 machine cycle=1 / 921.6Khz =1.085 micro seconds (11.0592 / 12 =921.6Khz).
In this program HERE loop time delay= 250*(2+1+1)* 1.085 X 10-6=1085 X 10-6 sec.
AGAIN loop repeats the HERE loop again 200 times ,so Time delay= 200*1085 X 10-6 = 217 ms
BACK loop repeats 100 times ,so 100 X 217ms=21700ms
However, the instructions “MOV R3,#250 and “DJNZ R2, AGAIN” at the beginning and end of the AGAIN loop add (3 x 200 x 1.085 us) = 651 us to the time delay
Total time delay =21.700651 sec
