You are on page 1of 7

LAB#5

NUST/PNEC
CS311

Objective: Learn To Generate Pulses by Using Delay Loop Techniques


Task: The frequency requirements are changed in Task Area
Part-1
Write and load a short program on Intel8051 to generate continues pulses of
a) Fifteen micro second duration
b) Twenty -millisecond duration
Create pulse On/Off time by using delay loop.

Part-II
By using Oscilloscope study and compare the following pulses/frequencies on the screen by
using 2/4-channel scope off Intel8051 control bus

a) Crystal clock
b) Read/Write pluses
c) ALE Clock
• Capture these images and show them to Lab demonstrator
• Add these images to your lab report

Pre lab report should include the following:


• Do all the calculation at home
• Software program
• Hardware Schematic

Material to be studied for pre lab report:


• Assembly language manual ‘A251’
• Material attached with this Lab
• Chapter # 2 Mackenzie
• Ref book: Mazidi

Post lab report should include the following:


• Source code file
• List file
• Your personal observations and procedural adjustment/
difficulties
• Results

1
The frequency requirements are changed in Task Area. Down below is an
example for different frequencies
You have to do proper calculation and replace the values to generate
required frequency

OBJECTIVE: To generate pulses by using Delay Loop Techniques

DESCRIPTION: The program generates continue pulses of five microseconds and five
milliseconds using software delay loop techniques and then the Clock, RD/WR and ALE
lines are inspected subsequently using the oscilloscope.

THEORY:
The microcontroller which is being used in the lab is 89C420, an ultra-high-speed
microcontroller or simply UHS microcontroller. It offers the highest performance
available in 8051-compatible microcontrollers and features a redesigned processor core
that executes every 8051 instruction up to 12 times faster. The most important thing to
note, however, is that it runs at 1 clock-per-machine cycle.

On an 11.0592 MHz crystal, each machine cycle takes 0.0904µs to execute. The
instruction set of the UHS microcontroller is exactly the same but the due to different
processing speed, the timings differ quite significantly. The UHS microcontroller clock
cycles for the instructions to be used in this program are given in the table on the next
page:

Instruction UHSM Clock Cycles


MOV Rn, #data 2
SJMP relative 3
DJNZ Rn, rel 4
NOP 1
CPL A 1

With the help of the clock cycles above, the code for the pulses will be developed in the
next section.

2
FIVE MICROSECOND PULSE

Initial Calculation

Since each clock cycle takes 0.0904µs to execute, the number of clock cycles required for
a 5µs pulse is:

5 / 0.0904 = 55.3 = 56 clock cycles approximately

Time Delay Explanation

Using the table above and following the order of the code, the number of machine cycles
taken by above program is:

SJMP + MOV + 12*DJNZ + NOP + NOP + CPL

3 + 2 + 12*4 + 1 + 1 + 1 = 56 clock cycles

Pulse duration = 56 clocks * 0.0904 µs/clock = 5.0624 µs

List File

A51 MACRO ASSEMBLER LAB5A


09/11/2007 17:31:14 PAGE 1

MACRO ASSEMBLER A51 V6.10


OBJECT MODULE PLACED IN .\lab5a.obj
ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE E:\Microcontroller\keil
lab\lab5a.a51 SET(SMALL) DE
BUG PRINT(.\lab5a.lst) OBJECT(.\lab5a.obj) EP

LOC OBJ LINE SOURCE

1 ; LAB # 5
2 ; To generate pulses by using delay loop

techniques
3 ; Group:
4 ; Five Microsecond Pulses
5 ; 29/August/2007
6

3
0000 7 ORG 0000H ;This sets the
origin at 00H
0000 790C 8 BEGIN: MOV R1,#0CH ;Move 0CH (12
dec.) in the register R1
0002 D9FE 9 LOOP: DJNZ R1,LOOP ;Loop, to produce
a delay of 12 * 4 cycles
0004 00 10 NOP ;Delay 1 cycle
0005 00 11 NOP ;Delay 1 cycle
0006 B291 12 CPL P1.1 ;Complement the
output
0008 80F6 13 SJMP BEGIN ;Jump back to the
beginning
14 END ;End of program
A51 MACRO ASSEMBLER LAB5A
09/11/2007 17:31:14 PAGE 2

SYMBOL TABLE LISTING


------ ----- -------

N A M E T Y P E V A L U E ATTRIBUTES

BEGIN. . . . . . . C ADDR 0000H A


LOOP . . . . . . . C ADDR 0002H A
P1 . . . . . . . . D ADDR 0090H A

REGISTER BANK(S) USED: 0

ASSEMBLY COMPLETE. 0 WARNING(S), 0 ERROR(S)

FIVE MILLISECOND PULSE

Initial Calculation

Since each clock cycle takes 0.0904µs to execute, the number of clock cycles required for
a 5ms pulse is:

5000 / 0.0904 = 55309.7 = 55310 clock cycles approximately

Time Delay Explanation

4
Using the table above and following the order of the code, the number of machine cycles
taken by above program is:

SJMP + MOV + 54*(MOV + DJNZ*255 + DJNZ) + CPL


3 + 2 + 54*(2 + 4*255 + 4) + 1 = 55310 clock cycles

Pulse duration = 55310 clocks * 0.0904 µs/clock = 5.000 ms

List File

A51 MACRO ASSEMBLER LAB5B

MACRO ASSEMBLER A51 V6.10


OBJECT MODULE PLACED IN .\lab5b.obj
ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE E:\Microcontroller\keil
lab\lab5b.a51 SET (SMALL) DE
BUG PRINT (.\lab5b.lst) OBJECT (.\lab5b.obj) EP

LOC OBJ LINE SOURCE

1 ; LAB # 5
2 ; To generate pulses by using delay loop
techniques
3 ; Group:
4 ; Five Millisecond Pulses
5 ; 29/August/2007
6
0000 7 ORG 0000H ;Sets the origin
to 00H
0000 7836 8 BEGIN: MOV R0,#36H ;Moves 36H in R0
to be used for external loop
0002 79FF 9 LOOP1: MOV R1,#0FFH ;Moves 0FFH in R1
to be used in internal nested loop
0004 D9FE 10 LOOP2: DJNZ R1,LOOP2 ;Internal Loop
Delay
0006 D8FA

11
DJNZ R0,LOOP1 ;External Loop Delay
0008 B291 12 CPL P1.1 ;Complement the
output bit
000A 80F4 13 SJMP BEGIN ;Jump back to the
beginning
14 END ;End of program
A51 MACRO ASSEMBLER LAB5B
09/11/2007 18:00:35 PAGE 2

5
SYMBOL TABLE LISTING
------ ----- -------

N A M E T Y P E V A L U E ATTRIBUTES

BEGIN. . . . . . . C ADDR 0000H A


LOOP1. . . . . . . C ADDR 0002H A
LOOP2. . . . . . . C ADDR 0004H A
P1 . . . . . . . . D ADDR 0090H A

REGISTER BANK(S) USED: 0

ASSEMBLY COMPLETE. 0 WARNING(S), 0 ERROR(S)

TIMING DIAGRAM

OBSERVATIONS

1. (a) The Crystal Clock (XTAL) frequency was noted ?????????


(b) ALE frequency was noted as:????????
(c) PSEN frequency was noted as:??????

2. In the 89C420 microcontroller ALE and clocks at 1/4th the system clock frequency,
which is exactly the result obtained on the oscilloscope.

3. The microcontroller is operating in the non-page mode, the default mode, after a
system reset.

6
4. ALE pulses are produced only when EA (External Access) pin is grounded, since it is
generated for external memory. If it is set to high noise is seen on the oscilloscope.

You might also like