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

Experiment-4 Delay Generation and Use of Kiel Debugger: Bjectives

This document describes using branch instructions and nested loops in 8051 assembly language to generate precise delays. It explains that delays are measured in machine cycles, which depend on the crystal oscillator frequency. DJNZ instructions can be nested in loops to generate a desired delay, taking 2 machine cycles each. The objectives are to understand delay generation and use a debugger to measure actual delays versus intended delays. Exercises are provided to generate a 5 second delay with less than 0.1% error and to switch LED patterns 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)
46 views3 pages

Experiment-4 Delay Generation and Use of Kiel Debugger: Bjectives

This document describes using branch instructions and nested loops in 8051 assembly language to generate precise delays. It explains that delays are measured in machine cycles, which depend on the crystal oscillator frequency. DJNZ instructions can be nested in loops to generate a desired delay, taking 2 machine cycles each. The objectives are to understand delay generation and use a debugger to measure actual delays versus intended delays. Exercises are provided to generate a 5 second delay with less than 0.1% error and to switch LED patterns 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 KIEL 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

THEORY:
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 of a program:
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.
Exercise#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 than
10−3 .

Exercise#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

You might also like