EEE 432 Lecture 11
EEE 432 Lecture 11
EMBEDDED SYSTEMS
Assembly Language
Programming (Cont.)
Lecture 11
1 Machine Cycle for the 8051
➢ The CPU takes a certain number of clock cycles to execute an instruction.
➢ In the 8051 family, these clock cycles are referred to as machine cycles.
➢ 8051 instructions are executed in a particular number of their machine cycles. To
calculate a time delay, we use these known machine cycles.
➢ In the 8051 family, the length of the machine cycle depends on the frequency of
the crystal oscillator connected to the 8051 system. The crystal oscillator, along
with on-chip circuitry, provide the clock source for the 8051 CPU.
➢ The frequency of the crystal connected to the 8051 family can vary from 4 MHz to
30 MHz, depending on the chip rating and manufacturer.
➢ In the original 8051, one machine cycle lasts 12 oscillator periods.
➢ Therefore, to calculate the machine cycle for the 8051, we take 1/12 of the crystal
frequency, then take its inverse, as shown in Example 1.
HERE: NOP 1
NOP 1
NOP 1
NOP 1
DJNZ R3,HERE 2
RET 2
EEE 432 - Embedded Systems (2024) 12
Example 4
Solution
➢ The time delay inside the HERE loop is
[250(1 + 1 + 1+ 1 + 2)] x 1.085 µs = 1500 x 1.085 µs = 1627.5 µs.
➢ Adding the two instructions outside the loop we have
1627.5 µs + 3 x 1.085 µs = 1630.755 µs
NOTE: If machine cycle timing is critical to your system design, make sure that you
check the manufacturer’s data sheets for the device specification. For example, the
DS89C420 has 3 machine cycles instead of 2 machine cycles for the RET instruction.