0% found this document useful (0 votes)
7 views

LAB7

This document discusses creating delays in assembly language programs for an 8051 microcontroller. It explains that delay length depends on the crystal frequency and number of clock cycles per machine cycle. It provides the formula to calculate machine cycle period based on crystal frequency for the 8051. An example assembly program is provided to generate a 10ms delay along with output and interpretation of results.

Uploaded by

REHAM DEE CAMAMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

LAB7

This document discusses creating delays in assembly language programs for an 8051 microcontroller. It explains that delay length depends on the crystal frequency and number of clock cycles per machine cycle. It provides the formula to calculate machine cycle period based on crystal frequency for the 8051. An example assembly program is provided to generate a 10ms delay along with output and interpretation of results.

Uploaded by

REHAM DEE CAMAMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Name:

Section:

Date Performed:

1. To be able to write an assembly language program to generate delay using register.


2. To develop skills to create the time delay by using instruction machine cycles and microcontroller
crystal frequency.

Creating a delay is most important and widely used function in almost all microcontroller-based
programming. Its use varies from creating a pause to allow microcontroller to interact with real world,
like blinking of LED, monitoring a switch or input at regular interval. In signal processing, a “delay” is
used to monitor signal at a predetermined sampling rate.

The delay length in 8051 microcontroller depends on two factors:


1. The crystal frequency.
2. The number of clock per machine.

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. In the 8051 family, the length of the machine cycle depends on
the frequency of the crystal oscillator connected to the 8051 systems. The crystal oscillator, along with
on-chip circuitry, provides 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.
Very often the 11.0592 MHz crystal oscillator is used to make the 8051 -based system compatible with the
serial port of the IBM PC. 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 below:

For 11.0592MHz/12 = 921.6KHz; machine cycle is 1/921.6KHz=1.085microsecond


Figure 7.2 Output Window
Step 3- Assembly Language Program

Memory
Hex Code Label Mnemonics Comments
Address

Observations for sample program (use blank sheet provided if space not sufficient)
Draw the waveform and mention the delay

Results for problem statement 1 (Output of the Program)


Provide screenshot(s) of the results like the output window in Figure 7.2 for problem statement 1
Interpretation of Results for problem statement 1 (Give meaning of the above obtained results)

The observed waveform indicating a delay of 10ms, as generated by the provided code, suggests that the
program successfully achieves the desired delay functionality. This delay is achieved through a combination of
nested loops in the DELAY subroutine, where the outer loop iterates 18 times and the inner loop iterates 255
times. The execution of these loops effectively consumes time, resulting in the observed delay. Additionally, the
toggling of the P1.1 pin before and after each delay further confirms the proper functioning of the program.
Therefore, the waveform's indication of a 10ms delay aligns with the expected behavior of the code, indicating
its successful execution.
Practical Related Questions

1. For an 8051 microcontroller how long will it take to execute the following
instruction. The crystal frequency is 11.0592 MHz
i) MOV R3,55H
ii) DEC R2.

2. On what factors does delay length depend upon?

3. For three different 8051 versions, what will be the machine cycle for the
following crystal frequencies:
i) 11.0592MHz
ii) 16MHZ
iii) 20MHz
Find period of machine cycle in each case.

You might also like