4. Program 1
• Write a program to set Port A as input port
and set Port B as output port in mode1 of
8255
• Steps:
• Initialize the control word for Port A as input and
Port B as output in Mode1
• Calculate the port address for Port A, Port B and
Control register
• Select the instruction for Read and write operation
9. • Program
MVI A, B4H -- Control Word
OUT 83H -- Control Register port Address
IN 80H -- Port A address
OUT 81H -- Port B address
HLT
10. Program 2
• Write a program to read DIP switches from
Group B and display the value in Group A in
mode0
Steps
• Calculate the port address
• Initialize the Control word
• Do the read and write operation
13. • Program
MVI A, 83H -- Control Word
OUT 83H -- Control Register port Address
IN 81H -- Port B address
OUT 80H -- Port A address
IN 82H -- Port C address
ANI OFH – Mask the upper four bits
RLC
RLC convert upper 4 bits to lower 4 bits (nibbles)
RLC PCU PCL
RLC
OUT 82H -- Port C address
HLT
14. Program 3
• Write the program to clear the PC3 and set
PC6 of 8255.
Steps:
• Calculate the port address
• Write BSR control word to set PC3 and to
clear PC6
• Select the write operation
15. • BSR Control Word to clear PC3
D7 D6D5D4 D3D2D1 D0
0 0 0 0 0 1 1 0
0 6 = 06H
16. • BSR Control Word to set PC6
D7 D6D5D4 D3D2D1 D0
0 0 0 0 1 1 0 1
0 D = 0DH
17. • Program
MVI A, 06H -- Control Word to clear PC3
OUT 83H -- Control Register port Address
MVI A, ODH -- Control Word to set PC6
OUT 83H -- Control Register port Address
HLT
18. Review of Importance
• The main function of Control word and the
BSR were implemented with the simple
programming. How to get the value from the
Keys or switches and how to store and
display in LEDs were discussed with simple
example programs. The calculation of port
addresses from the interfacing and the bit set
or reset of PortC illustrated with simple
program
19. Questions
• Write the control word to set all ports as
input port in mode0
• Write the program to read the data from
portC upper to lower
• Write the BSR to set the 4,5,6 bit position of
portC
20. Synopsis
• The initialization of Control word and the BSR
control word were implemented with the
simple programming. The processor
interfaced with peripherals like the input
devices (switch or key) were read and the
some data were written into the output
device (LEDs) executed with programming.
The calculation of port addresses from the
interfacing and how to use in the program
were discussed.
22. Program 4
• Write a program to set PC4 for 4 ms and then
reset the bit in 8255
Steps:
• Calculate the port address
• Write the BSR word
• Do the write operation
• Set count value for 4ms
23. • BSR Control Word to set PC4
D7 D6D5D4 D3D2D1 D0
0 0 0 0 1 0 0 1
0 9 = 09H
24. • Program
MVI A, 09H -- BSR Word to set PC4
OUT 83H -- Control Register port Address
CALL Delay – delay for 2ms
MVI A, O8H -- BSR Word to clear PC4
OUT 83H -- Control Register port Address
HLT
26. PROGRAM 5
Design a counter with 2 ms delay and set port B
to display the value.
Steps:
• Calculate the port address
• Write the control word
• Do the write operation
• Set count value for 2ms
27. • Program
MVI A, 80H -- Control Word
OUT 83H -- Control Register port Address
MVI B, OAH -- initialize the counter value
L1 MOV A,B
OUT 81H -- Port B address
CALL DELAY -- Delay for 2 ms
DCR B -- for next counter value
JNZ L1
HLT -- stop the program
DELAY
LXI B, 011EH -- initialize the delay/ counter value
L2 DCX B
MOV A,C -- decrement till zero
ORA B
JNZ L2
RET
28. Time delay
• Delay program for 8 bit
MVI C, FFH 7T TO
LOOP DCR C 4T
JNZ LOOP 10T TL = 14T