Professional Documents
Culture Documents
Labsheet Ece521 Intel8051 Sept2013 PDF
Labsheet Ece521 Intel8051 Sept2013 PDF
Labsheet Ece521 Intel8051 Sept2013 PDF
0
A
B
R0
R1
0
PSW
R2
SP
R3
R4
15
R5
8 7
DPL
DPH
R6
0
DPTR
PC
R7
ECE521/SEPT2013/8051/Pg 1
There are three types of data transfer instructions provided by Intel 8051 microprocessor:
a) MOV, MOVC, MOVX
c) XCH and XCHD
b) PUSH and POP
Data transfer instructions involve instructions such as MOV, MOVC, MOVX to copy or move
data between the various locations.
EQUIPMENTS
1. A Personal computer installed with the MCU 8051 IDE Editor/Assembler/Simulator
2. Intel 8051 Trainer Board.
PROCEDURE
All the programs in the exercises have to be written and assembled using the MCU8051IDE
Assemble/simulator. To observe the results, the programs have to be compiled and executed in
the Simulator. The contents of the affected registers and memory locations have to be
examined through single stepping or breakpoints setting.
EXERCISES
1. Write a program that will store 30H into Accumulator A, 48H into R0 and D8H into R1.
Execute the program and explain the differences in the results.
2. Write a program that will store 2004H in DPTR. Execute the program and comment on the
results.
3. Write and execute a program that will store data 21H into external memory location
2050H. Explain the results.
4. Write a program that will send logic 11010011B to R5. Execute the program and comment
on the results.
5. Write a program that will exchange data between R0 and ACC A. Execute the program and
comment on the results.
ECE521/SEPT2013/8051/Pg 2
2. Write and execute a program that adds the four 8-bit numbers 10H, 5FH, B9H and CFH
The result must be stored in external memory location 1500H. Comment on your results.
3. Write and execute a program that will subtract 15H from F0H. Store the result in memory
location 2000H and explain the results
4. Write and execute a program that multiply 22H by 04H using MUL. Explain on the result
obtained.
5. Write and execute a program that divides 02H by 50H using DIV. Explain on the result
obtained.
ECE521/SEPT2013/8051/Pg 3
6. Write and execute a program that logically AND the data in R4 with 55H. Put any data in
R4 and explain on the result obtained.
7. Modify Part 6 to perform a logical OR for the same data. Execute the program and explain
on the results obtained.
8. Load any data into R5. Rotate the data to the right twice. Execute the program and explain on
the results obtained
ECE521/SEPT2013/8051/Pg 4
EQUIPMENTS
1. A Personal computer installed with the MCU 8051 IDE Editor/Assembler/Simulator.
2. Intel 8051 Trainer Board
PROCEDURE
All the programs in the exercises have to be written and assembled using the MCU 8051 IDE
assembler/simulator. To observe the results, the programs have to be compiled and simulate.
The contents of the affected registers and memory locations have to be examined through
single stepping or breakpoints setting.
ECE521/SEPT2013/8051/Pg 5
EXERCISES
1. Write and execute a program that copy twelve bytes of data starting from memory locations
1000H to memory locations starting 100BH.
2. Write and execute a program that place the larger of the contents of memory locations
1200H and 1250H into memory location 1300H.
3. Three hexadecimal numbers are stored in memory locations 1010H, 1011H and 1012H.
Sort these numbers into ascending order with the smallest number in memory location
1013H.
4. Write a program, which inspect the contents of memory location 1008H and, if the contents
are greater than 0AH, subtract the value with 05H and store the result in memory location
200AH. Otherwise, add it with 10H and store the result in location 200BH.
5. Twelve 8-bit numbers are stored in memory locations starting with 1250H. Add the content
of these memory locations using indirect addressing mode and looping technique.
Execute the program and explain on the result obtained.
6. Write and execute a program that compute the area of two rectangular whose width and
length are stored in memory locations 2100H and 2101H, and save the area of these
rectangular in memory locations 2200H and 2300H. The calculation process of the area
must be done in a subroutine.
ECE521/SEPT2013/8051/Pg 6
The Base address for PPI can be determined from memory decoder circuit. The address for
PortA, PortB and PortC are then set based on PPI Base address according to the following
table.
A1
A0
I/O ASSIGNMENT
PORT A
PORT B
PORT C
CONTROL REGISTER
ECE521/SEPT2013/8051/Pg 7
BASE ADDRESS
PORTA
PORTB
PORTC
CR
$4000
$4000
$4001
$4002
$4003
$8000
$8000
$8001
$8002
$8003
Table 2: Example of Port and Control Register Addresses for different Base address.
Once the address for each port have been determined, the PPI must be
initiallize/programmed according to your input/output requirement. Each port can be set as
input or output by setting individual bit in Control Register as shown in firgue below. Only
Mode 0 is allowed for this Lab Session. Mode set Flag must be set to 1 to enable the PPI.
PORTA
PORTB
PORTC
Upper
PORTC
Lower
CR
Input
Input
Input
Input
9BH
Output
Output
Output
Output
80H
Output
Input
Output
Input
83H
EQUIPMENTS
1.
2.
3.
4.
EQUIPMENTS
The assembly language programs can be written, assembled and executed using MCU8051IDE
assembler/simulator. The Intel 8051 Trainer Board comes complete with 8051 Application Board
which enables all the programs to be tested with the appropriate Setting. Table 1 shows the actual
Setting of various devices on the Application Board and their connections to 82C55 Programmable
Peripheral Interface (PPI) device.
Table 1: The connections of the input and output devices on Intel 8051
Application Board to the 82C55 Programmable Peripheral Interface (PPI) device.
No
1
Device
Address
Port
7-Segment 1 82C55A0
6000H
PortA.0-PortA.3
7-Segment 2 82C55A0
6000H
PortA.4-PortA.7
82C55A0
6001H
82C55A0
6002H
Control RS PortC.5
82C55A0
6002H
Control E PortC.4
82C55A1
8001H
Control En PortB.0
82C55A1
8001H
82C55A1
8001H
82C55A2
A002H
Row - PortC
82C55A2
A000H
Col - PortA
LCD
DC Motor
Dot Matrix
PPI
Buzzer
82C55A1
8001H
PortB.7
LED
82C55A1
8002H
PortC
Switch
82C55A3
E001H
PortB
Ext Con2
82C55A1
8000H
PortA
Ext Con3
82C55A2
A001H
PortB
10
Ext Con4
82C55A3
E000H
PortA
8001H
PortB.5
11
12
KeyPad
82C55A3
E002H
Row PortC.4-PortC.7
KeyPad
82C55A3
E002H
Col PortC.0-PortC.3
ECE521/SEPT2013/8051/Pg 9
PROCEDURE
All the programs in the exercises have to be written and assembled using the MCU8051IDE
simulator. To observe the results, the programs have to be downloaded and executed on the
Intel 8051 CPU Trainer Board. The application board has to be connected to the CPU Trainer
Board before executing the program. The contents of the affected registers and memory
locations have to be examined through single stepping and breakpoints setting if necessary.
EXERCISES
1. Write and execute a program that turns on LED one by one as Running Light.
2. Write and execute a program that reads the condition of 8 switches and send the logic signal
to the LED.
3. Write and execute a program that display number on both 7 segment counting up from 00 to
99.
4. Write and execute a program that can turn the DC motor Clock-wise for 5 second and then
stop. After 3 second rest, the motor repeat the same step again and the loop repeated all
over again
5. Write and execute a program that read the keypad button and display the number on 7Segment.
ECE521/SEPT2013/8051/Pg 10