MICROPROCESSOR INTERFACING &
PROGRAMMING
                                                                                                                                            (EL-303)
                                                                                  LABORATORY MANUAL
          Lab # 07: To Setup 4-Digit Multiplexed Seven Segment
               Displays on a Single Port of Microcontroller
                                                                         Student Name: ______________________________________________
                                                                                 Roll No: ________________ Group No: ____ Section:_____
                                                                                                             Date performed: _____________, 2020
_________________________________________________________________________________________________________________________________________________________
  NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES, CHINIOT- FAISALABAD
           Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
    EXPERIMENT 7                                                    Date Perform: ________________
   To Setup 4-Digit Multiplexed Seven Segment Displays on a Single
                       Port of Microcontroller
Lab Objectives:
   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.
Arithmetic Commands Syntax:
___________________________________________________________________________________________
                                                                        Page 3 of 6
            Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
 1. ADD Instruction:                                    2. SUBB Instruction:
 Syntax:      ADD A, source                             Syntax:      SUBB A, source
 Effect:          A = A + source                        Effect:            A = A – source – CY
 The instruction ADD is used to add two operands.       In many microprocessors there are two different
 Destination operand is always in register A Source     instructions for subtraction: SUB and SUBB (subtract
 operand can be a register, immediate data, or in       with borrow). In the 8051 we have only SUBB. The
 memory.                                                8051 microcontroller uses adder circuitry to perform
                                                        the subtraction. To make SUB out of SUBB, we have
                                                        to make CY=0 (CLR PSW.7 or CLR C) prior to the
                                                        execution of the instruction. Notice that we use the
                                                        CY flag for the borrowing.
                                                        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
                           Attach the code and proteus results with manual
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.
Note: Use indirect register addressing mode to create a list.
                           Attach the code and proteus results with manual
___________________________________________________________________________________________
                                                                        Page 5 of 6
           Lab Manual of ‘MICROPROCESSOR INTERFACING AND PROGRAMMING’
             EL303 – MICROPROCESSOR INTERFACING AND PROGRAMMING LAB
 To enable the students to write effective assembly language programs using various addressing
 modes, jumps, timers, counters, and interrupts. Also enabling them to interface any external hardware
 using serial programming and verifying the results either through simulators or through actual
 hardware.
 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.
                                                                                CLO        MARKS OBTAINED
                                                                                 1
                                                                                  3
                                                                               Lab Engineer Signature: ________________
___________________________________________________________________________________________
                                                                        Page 6 of 6