Many times, it is necessary to generate time delays. For example, to generate a square wave we have to generate a delay of T/2 period so that we can make output 1 for T/2 period and make output 0 for T/2 period. Let us see how to calculate exact delays for 8051.
Time Delay for 8051
Many
times, it is necessary to generate time delays. For example, to generate a
square wave we have to generate a delay of T/2 period so that we can make
output 1 for T/2 period and make output 0 for T/2 period. Let us see how to
calculate exact delays for 8051.
For
8051 operating frequency is one-twelfth (1/12) of the crystal frequency.
Therefore, one machine cycle lasts for 12 oscillator periods.
ஃ
Machine cycle period = 12 / Crystal frequency
For
crystal frequency 11.0592 MHz,
Machine
cycle period = 12 / 11.0592 × 106
= 1.085 µs
For
8051, we know that how much machine cycle/s are required to execute the
particular instruction. Therefore, we can calculate the exact time for
execution of that instruction, as shown below.
Example
15.9.1 Calculate the time delay produced by the
following subroutine.
Delay
: MOV R1, #30
HERE
: DJNZ R1, HERE
NOP
NOP
RET
Solution
:
Let us assume the crystal frequency of 8051 is 11.0592 MHz. Therefore, the
period of the machine cycle will be
Time
delay = [1 + (2 × 30) + 1 + X + 1] × 1.085 µsec = 69.44 µs
Here, (2 × 30) indicates that the instruction DJNZ RI, HERE is executed 30 times.
Microprocessors and Microcontrollers: Unit III: (b) 8051 Instruction Set and Programming : Tag: : - Time Delay for 8051