0% found this document useful (0 votes)
80 views3 pages

Experiment - 4: Delay Generation and Use of Keil Debugger

This document discusses using branch instructions and nested loops in 8051 assembly language to generate precise delays. It explains that delays are calculated based on the crystal oscillator frequency and number of machine cycles needed. The Keil debugger can measure actual delay times and errors. Exercises are provided to write programs that generate 5-second delays with less than 0.1% error and toggle LED patterns in groups every 2 and 8 seconds.

Uploaded by

Umair Hameed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views3 pages

Experiment - 4: Delay Generation and Use of Keil Debugger

This document discusses using branch instructions and nested loops in 8051 assembly language to generate precise delays. It explains that delays are calculated based on the crystal oscillator frequency and number of machine cycles needed. The Keil debugger can measure actual delay times and errors. Exercises are provided to write programs that generate 5-second delays with less than 0.1% error and toggle LED patterns in groups every 2 and 8 seconds.

Uploaded by

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

EXPERIMENT - 4

DELAY GENERATION AND USE OF KEIL DEBUGGER

OBJECTIVES:
 To understand the use of branch instructions available in 8051 assembly language.
 To be able to generate a given amount of delay using nested loops such that error is
minimum in the delay

EQUIPMENT/TOOLS:
 KeilμVision.3IDE

BACKGROUND:
Every microprocessor needs a clock to execute the program. CPU executing an
instruction takes a certain number of clock cycles. These are referred to as machine cycles.
The length of machine cycle depends on the frequency of the crystal oscillator connected to
8051. In original 8051, one machine cycle lasts 12 oscillator periods. We may use DJNZ
instructions to make nested loops to generate desired amount of delay. Each DJNZ takes 2
machine cycles.
Oscillator frequency=f os
Amount of delay required=t 0
f os × t 0
No .of machine cycles required ¿ generate ¿ delay =
12
f os ×t 0
No .of DJNZs required ¿ generate ¿ delay=
12 ×2
Following examples demonstrate how to compute the execution time in of a program:
Lab Manual of Microprocessor Interfacing & Programming

Two factors can affect the accuracy of the delay:

1. Crystal frequency: The duration of the machine cycle is a function of this crystal
frequency.
2. 8051 design: The original machine cycle duration was set at 12 clocks. Advances in
both IC technology and CPU design in recent years have made

We can use debugger of our IDE to find the time taken by the processor to execute a
program. Following figure demonstrates

Page | 2
Lab Manual of Microprocessor Interfacing & Programming

EXERCISES:

1. Write an assembly language program to generate a delay of 5 seconds. Use debugger to


measure actual delay and then compute the percentage error in your program. Now optimize
your program to minimize the error in delay. The percentage error should be less than10−3 .

2. Eight LEDs are required to glow according to the patterns mentioned in the table below.
There are two groups of patterns. Each group consists of two patterns. You are required to
design and implement an algorithm that switch between the two patterns every 2 seconds.
Moreover, groups are switched every 8 seconds.

Note: The red color of LED represents HIGH logic and green color represents LOW logic.

Group#
1
Group#
2

Page | 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy