Professional Documents
Culture Documents
Microprocessor Interfacing & Programming: Laboratory Manual
Microprocessor Interfacing & Programming: Laboratory Manual
Microprocessor Interfacing & Programming: Laboratory Manual
PROGRAMMING
(EL-303)
LABORATORY MANUAL
_________________________________________________________________________________________________________________________________________________________
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES, CHINIOT- FAISALABAD
Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
1. To learn to control seven segment display decoder, and to understand the function of multiplexed
array of four digit seven-segment decoder
2. To understand and implement refresh rate in case of a display
3. To learn a method of displaying a 4-digit number on an output device using the 89C52 micro-
controller
Equipment Required:
1. KeilμVision IDE
2. ATMEL ®89C52 Microcontroller Kit
3. XELTEX Universal Burner
4. 7-Segment display (4-digit)
Background:
The seven-segment display decoder is a combination of 7 LEDs capable of displaying all the digits of
the hexadecimal system. A single Seven Segment decoder unit can have either common anode or
common cathode configuration. The diagram below shows a four digit multiplexed array of seven-
segment decoders in common anode configuration. Providing logic 1 to any of a1, a2, a3, or a4 selects
that particular digit. Writing 0 to any of a, b, c, d, e, f or g lights up that segment.
Figure 1
___________________________________________________________________________________________
Page 2 of 6
Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
The assignment of pin-outs and the formation of digits are shown below:
Figure 2
A 4-digit hexadecimal number is displayed on the four-digit unit by continuously refreshing the four
seven segment display units. The rate at which the display is refreshed should be fast enough to prevent
flickering. In general, the whole four digit display should be refreshed at least 25 to 30 times a second
(much above the minimum criteria of 16 times per second). However, in this experiment we will be
refreshing it at a much faster rate of 250 times per second or with a period of 4 msec, thus making ON
each digit for 1ms in one iteration.
___________________________________________________________________________________________
Page 3 of 6
Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
4. MUL Instruction:
3. DIV Instruction: Syntax: MUL AB
Syntax: DIV AB Effect: AxB, 16-bit result in B= high byte,
Effect: Divide A by B, A=Quotient, A= low byte
B=Remainder The 8051 supports byte by byte multiplication only.
The 8051 supports bytes over byte division only, the The bytes are assumed to be unsigned data.
byte are assumed to be unsigned data.
___________________________________________________________________________________________
Page 4 of 6
Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
Lab Exercise
Task 1:
Write a program that takes two 4-bit numbers (A and B) as input and performs the required arithmetic
operation according to the selection value in register R0. If R0 = 1, then perform A+B. If R0 = 2, then
perform A*B. The result along with the two numbers must be displayed on multiplexed 4-digit common
anode 7-segement display. The result is shown in decimal base until it is 2-digit; if the result is 3-digit in
decimal then the result must be shown in hexadecimal base.
Example#1:
If R0 = 1, A = 5 and B = 8 then “5 8 1 3” must be displayed.
If R0 = 2, A = 5 and B = 8 then “5 8 4 0” must be displayed.
Example#2:
If R0 = 1, A = 15 and B = 10 then “F A 2 5” must be displayed.
If R0 = 2, A = 15 and B = 10 then “F A 9 6” must be displayed.
In example#2 the result of 15*10 = 150 in decimal (3-digit) that is why the result is shown in
hexadecimal base i.e., 96H
Task 2:
We have a list of ten 4-digits numbers stored in the ROM in the form of comma-separated strings. Like
"list db: “1234”, “6789”, ……..”3458”.
Write a program to display first complete number on 7-segment display for one second, then display the
next number for one second, and so on.
___________________________________________________________________________________________
Page 5 of 6
Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
CLO Statement ↓ Exemplary (5) Proficient (4) Developing (3) Beginning (2) Novice
Score → (1)
Behaves
responsibly within Takes ownership Actively works Partially work Needs help from Does not
and Works and participates and participate in others group to work
team, and perform
1 actively in group group complete
the experiment throughout the discussions. discussions assigned task
safely. lab
Design and
development of a Correctly With minor With major Partially Does not
microcontroller- develops the mistakes mistakes develops the work
based system to microcontroller- develops the develops the microcontroller-
2 based system microcontroller- microcontroller- based system
solve an based system based system
engineering
problem.
___________________________________________________________________________________________
Page 6 of 6