Professional Documents
Culture Documents
MICROPRESSOR SYSTEM
Equipments :
1. Computer station with Windows OS and MY1 8085 simulation program
2. 8085 Instruction Sets (Assembly Code)
3. 8085 Instruction Sets (Machine Code)
Introduction
The 8255 Programmable Peripheral Interface (PPI) is the general purpose
interface device which is widely used in Intel 8085 microprocessor design. It
contains three independent 8 bit ports named Port A, B and C. Port A and B can be
programmed as either input or output (all eight line must be same), while port C is
split into two 4 bit halves (Port C upper (PC4-PC7) and Port C lower (PC0-PC3) that
can be separately programmed as input or output.
A0 Port A (8 Bit)
A1 PPI 8255
Port B (8 Bit)
RD
WR Port C (8 Bit)
CS
There are four register that control the operations of the PPI and there are mapped
to four address locations in the 8085 Development System as shown below:
Port Address
Port A Register 80H
Port B Register 81H
Port C Register 82H
Control Register 83H
1
UniMAP
EKT222 Miroprocessor Systems Lab 4
A0 A1 CS RD=1 WR=0
Port A to Data
0 0 0 Data bus to Port A
bus
Port B to Data
0 1 0 Data bus to Port B
bus
Port C to Data
1 0 0 Data bus to Port C
bus
Data bus to Control
1 1 0 -
Register
The control register is used to configure the PPI into a variety of operation modes.
There are three basic modes:
We will only concentrate at mode 0. Further descriptions about mode 1 and 2 can
be referred to the 8255 datasheet. Mode 0 provides for simple input output
operations with no handshaking. This means that data either to or from the port
does not depends to other signal for data transfer. Basically, to configure the PPI, a
control word must first be sent to the control register @ port 83H. Figure 1
summarizes the control word format.
2
UniMAP
EKT222 Miroprocessor Systems Lab 4
The instruction below is an example used to configure the PPI so that port A
functions as input and port B & C as output.
When the control port is configured, the data can be sent to any of the output port
using OUT instruction. For example, if a data is to be sent to the Port B. The data
must first be loaded into the accumulator and OUT instruction is used as below.
MVI A, 55H
OUT 81H ; where 81H is the address of Port B
3
UniMAP
EKT222 Miroprocessor Systems Lab 4
The processor speed is very fast in dealing the fetch and execute cycles.
Normally humans tend to ignore internal processes especially when a faster
operation gives quicker result than slower processors. But when dealing with inputs
and outputs, certain conditions do require a more moderate speed for humans to
accommodate.
Basically, the NOP instruction code can be used as a simple delay cycle for the
microprocessor. A longer delay program can be seen as :
MVI C, 255
LOOP: DCR C
JNZ LOOP
This program forms a loop which will decrease the contents of register C by 1 until
gradually reaches 0. Any instructions after JNZ will be executed after register C
equals to zero. This loop will create a delay that can be used for certain
microprocessor application. The time delay depend’s on the instruction set which
determines the T-state for each instruction. (Please refer to Instructions Code
Summary). The following example shows the calculation of the software delay
routine.
Where
T state, Ts=1 / (0.5 x crystal frequency)
T state, Ts= 325 ns. Time delay, td=3574 x 325 ns = 1.16 ms.
4
UniMAP
EKT222 Miroprocessor Systems Lab 4
DELAY: MVI B, x1
LOOP: MVI C, x2
LOOP1: DCR C
JNZ LOOP1
DCR B
JNZ LOOP
Or
DELAY: LXI B, N
LOOP: DCX B
MOV A, B
ORA A
JNZ LOOP
5
UniMAP
EKT222 Miroprocessor Systems Lab 4
1. The 8085 Simulator, MY1 Sim85, also provides hardware devices to the user.
By default once the software is opened, an 8-bit LED device is assigned to
Port A @ 80H and an 8-bit SWITCH device is assigned to Port B @ 81H.
2. Input output device selections can also be done by choosing Devices from the
Main Menu.
1
2
6
UniMAP
EKT222 Miroprocessor Systems Lab 4
LABORATORY TASK
In this task, we will observe how to assign an output to an LED. Given is the program
to display 1-bit LED :
1 ORG 0000H
2 MVI A,80H
3 OUT 83H
4 MVI A,0
5 OUT 80H
6 MVI A,1
7 OUT 80H
8 HLT
DISCUSSION
1. Step simulate the program above and observe the LED display. Which LED
lights up?
7 6 5 4 3 2 1 0
2. Remove PA0 and PA4 from the LED0 and LED4 display and swap the ports
assignment. LED0 assign with PA4 while LED4 assign with PA0. Step simulate
again and explain your observation.
3. Reset the LEDs with the proper port assignments. Change the instruction at
line 6 to:
MVI A,16.
7
UniMAP
EKT222 Miroprocessor Systems Lab 4
ORG 0000H
MVI A,10011000B
OUT 83H
MVI B,01H
LOOP: MOV A,B
OUT 80H
RLC
MOV B,A
JMP LOOP
HLT
DISCUSSION
4. Step simulate the program and observe the operation. What can you say
about the running lights coming out at Port A of the PPI?
5. Set the PPI control register so that Port B is an input port switch. What is the
suitable program to show the running light when the switch at PB0 is turned
on but pauses when it is turned off? Step simulate your modified program.
8
UniMAP
EKT222 Miroprocessor Systems Lab 4
6. Instead of step simulate as in steps 4 and 5, run your simulation and observe
the running light. Since the running light is moving at high fequency, you will
need to reduce the clocking frequency to adjust to your eye movement.
Create a delay subroutine to delay the running light by at least 5 clock cycles.
Remember to set the stack memory location when using the CALL/RETURN
instructions.
9
UniMAP
EKT222 Miroprocessor Systems Lab 4
EXERCISE
2. Figure 1 shows the connection between LED and switch with 8255 I/O port.
Write a program to make the LED blink when the switch is ON and stop
blinking when the switch is OFF. VCC
U3 SW2
34 4 1 16
33 D0 PA0 3 2 15
32 D1 PA1 2 3 14
31 D2 PA2 1 4 13
30 D3 PA3 40 5 12
29 D4 PA4 39 6 11
28 D5 PA5 38 7 10
27 D6 PA6 37 8 9
D7 PA7
5 18 SW DIP-8
36 RD PB0 19
9 WR PB1 20
8 A0 PB2 21 VCC
35 A1 PB3 22
6 RESET PB4 23
CS PB5 24
PB6 25
PB7
14
PC0 15
PC1 16
PC2 17
PC3 13
PC4 12
PC5 11
PC6 10
PC7
8255
Figure 1
3. Figure 2 below shows the connection interface of four switches and LED with
Port A and Port C. The switches represent as a 4-bit data input. Write a
program to read 4 bit data input from the switches and the value will be used
to determine how many time the LED should blink.
VCC
U3 SW2
34 4 1 16
33 D0 PA0 3 2 15
32 D1 PA1 2 3 14
31 D2 PA2 1 4 13
30 D3 PA3 40 5 12
29 D4 PA4 39 6 11
28 D5 PA5 38 7 10
27 D6 PA6 37 8 9
D7 PA7
5 18 SW DIP-8
36 RD PB0 19
9 WR PB1 20
8 A0 PB2 21 VCC
35 A1 PB3 22
6 RESET PB4 23
CS PB5 24
PB6 25
PB7
14
PC0 15
PC1 16
PC2 17
PC3 13
PC4 12
PC5 11
PC6 10
PC7
8255
Figure 2
10
UniMAP
EKT222 Miroprocessor Systems Lab 4
4. Using two push-pull switches and eight LEDs, write a program of an 8-bit
running light that will have the following specifications shown in Table 1 :
Table 1
5. Write a program that will display a MOD-16 counter onto a 4-bit LED.
6. A BCD counter is to be displayed onto a 4-bit LED. Write a program that will
count the BCD counter on every push button.
Figure 3
On every clock pulse, the upper 4-bit will shift to the right while the lower 4-
bit will shift towards the left. When the upper 4-bit reaches its LSB it will
change direction and shift to the left. The same will happen to the lower 4-bit
once it reaches its MSB, it will change direction and shifts to the right.
11
UniMAP