Air University: Department of Electrical and Computer Engineering
Air University: Department of Electrical and Computer Engineering
Air University: Department of Electrical and Computer Engineering
EXPERIMENT NO3
LAB ASSESSMENT:
Data presentation
Experimental results
Conclusion
Date: Signature:
EXPERIMENT 03
Objective:
Equipment:
Hardware:
1. 8051 microcontroller
2. Seven segment displays (SSDs)
3. Resistances
Software:
1. Keil µVision
2. SmartPRO 5000U
Introduction:
In this addressing mode the source operand is a constant. In immediate addressing mode, when the
instruction is assembled, the operand comes immediately after the opcode. Notice that the data in
this instruction must be preceded by pound sign. For example:
mov A,#25h
Lookup Table:A lookup table is an array that replaces runtime computation with a simpler array
indexing operation. The savings in processing time can be significant, because retrieving a value from
memory is often faster than carrying out an "expensive" computation or input/output operation. The look-
up table allows access to elements of a frequently used table with minimum operations. We design a
lookup table of our desired values which can be accessed by data pointer. It is a very useful method in
various implementations of several applications i.e., you can save many quantization points to represent a
sin wave and you can send them one by one to any port and interfacing a digital to analog converter with
that port will change these levels to their analog equivalent levels producing a sin wave.
Seven Segment Displays:The seven segment display IC is LT-541 or LSD5061-11. Each of the
segments of the display is connected to a pin on the 8051. In order to light up a segment on the pin must
be set to 0V. To turn a segment off the corresponding pin must be set to 5V. This is simply done by
setting the pins on the 8051 to ‘1’ or ‘0’. SSDs are
However, they are cheaper than LCD display. 7-SEG Display is available in two types:
1. Common anode
2. Common cathode
Common anode displays are most suitable for interfacing with 8051 since 8051 port pins can sink current
better than sourcing it.
In common anode the common terminal is tied to +5V through a resistance and 0V should be provided to
the segment you need to glow or turn on.
The following pin assignment and bit sequence is used for common anode SSD interfacing with 8051.
Cathode pins should be connected through resisters to limit current. Anode is tied to 5V
source.Procedure:
Use port 2 to implement a single digit counter and connect it from LSB to MSB in a sequence
starting from segment a tosegment h.
While implementing a two digit counter use port 3 for 2nd digit and make sure you connect the port
in the same way as you connected for first digit.
It is better to use resistances with Seven Segment Displays to limit the current to avoid overheating.
Example:
org 000h
mov A,#11111001b
mov P2,A
call delay
call delay
delay: mov r0,#04
here: mov r1,#255
again1: mov r2,#255
again2: djnz r2,again2
djnz r1,again1
djnz r0,here
ret
end
Lab Task 1:
Write an assembly language code to display numbers from 0-9 using a common anode SSD. Use a time
delay of 0.5 seconds between each transition. Burn this code on 8051 microcontroller chip and interface
with SSD to obtain the results. Verify the results in Proteus.
EXPLANATION:
We will make a look up table of common anode seven segment display at first
We will access the location of lookup table through dptr.
We will use movc command to move dptr in accumaltor using port 2
The time delay will e of 0.5 sec
After creating dealy function we will end the coe , burn it.
Generate a hex file of code.
Verify results in proteus
CODE:
org 50h
db 11000000b, 11111001b, 10100100b,10110000b, 10011001b, 10010010b, 10000010b,
11111000b, 10000000b, 10010000b
org 00h
now: mov dptr,#50h
mov r1,#10
next: clr A
movc A, @A+dptr
mov p2,A
call delay
inc dptr
djnz r1,next
sjmp now
delay: mov r5, #04
here: mov r6,#255
again: mov r7,#255
againn: djnz r7, againn
djnz r6, again
djnz r5,here
ret
end
PROTEUS SUIMULATION:
Lab Task 2:
Write an assembly language code to display numbers from 9-0 using a common cathode SSD. Use a time
delay of 0.5 seconds between each transition. Generate the hex file for this code and verify the results in
Proteus.
EXPLANATION
We will make a look up table of common cathode seven segment display at first
We will access the location of lookup table through dptr.
We will use movc command to move dptr in accumaltor using port 2
The time delay will e of 0.5 sec
After creating dealy function we will end the coe , burn it.
Generate a hex file of code.
Burn hex file in proteus and verify results
CODE:
ORG 50h
db 01101111b , 01111111b, 00000111b, 01111101b, 01101101b,01100110b,
01001111b,01011011b,00000110b, 00111111b
ORG 0000h
main:mov dptr,#50h
mov r1,#10
repeat:clr A
movc A,@A+dptr
mov P2,A
call delay
call delay
inc dptr
djnz r1,repeat
sjmp main
EXPLANATION:
We will make a look up table of common cathode seven segment display at first
We will access the location of lookup table through dptr.
We will use movc command to move dptr in accumaltor using port 2
The time delay will e of 0.5 sec
After creating dealy function we will end the coe , burn it.
Generate a hex file of code.
Burn hex file in proteus and verify results
CODE:
org 500h
db 00111111b, 00000110b, 01011011b, 01001111b, 01100110b, 01101101b, 01111101b, 00000111b,
01111111b, 01101111b
org 00h
now: mov dptr,#500h
mov r1,#10
next: clr A
movc A, @A+dptr
mov p2,A
call delay
inc dptr
djnz r1,next
sjmp now
delay: mov r5, #04
here: mov r6,#255
again: mov r7,#255
againn: djnz r7, againn
djnz r6, again
djnz r5,here
re
end
PROTEUS SIMULATION:
Conclusion:
In this lab we learned about the use of lookup table. We were able to display data sent on the output
port on seven segment display.We also got familiar with the addressing modes. We were able to
do our coding as specified by the instructor in particular addressing mode. We are now able to
code in assembly language effectively.