Beruflich Dokumente
Kultur Dokumente
Introduction
8255A is one of the mostly used programmable, Parallel I/O device. It can be used to transfer the data on various conditions. When ever multiple I/O ports are required, 8255A is used for flexible interfacing between MPU and I/O peripherals.
Introduction
3
MPU interface to external devices through both parallel and serial interfaces. Parallel data occur in system that use:
About (8255A)
24 I/O pins 8 bit parallel ports: A, B C port: can be grouped as 4 bits CU(C upper) and CL(C Lower) Two Modes: BSR(Bit Set/reset) mode and I/O mode BSR mode (set/reset) in port C only. I/O mode is further divided in 3 modes:
Mode 0 : simple I/O Mode 1 : Handshake Mode 2 : Bidirectional
Pin Diagram
8255A
PIN Description
8255A is having 24 I/O pins. This 24 are divided in 3, 8-bit ports(A,B,C). Port C can be used as individual pins or it can be grouped in 2, 4-bits port (C-upper, C-lower). The functions of this port A,B,C is been written on Control register (CR). RD(AL): When this signal is low, MPU reads data from selected I/O port. WR(AL): When this signal is low, MPU Writes the data into selected I/O port or Control Register. Reset : It is active high signal, it clears the bits in control register.
Port address is determined to pins Ao and A1. CS (AL) is been used to select the 8255A If A7=1, and A6-A2=0. Ports will be having the address from 80H to 83H
Control Register
I/O mode
BSR mode
Modes in 8255A
Bit SET/RESET mode :- Used to set and reset the bits in port C only
Mode 0:All ports will function as simple I/O ports Mode 1:Hand shake Mode Mode 2: Port A can be SET for bidirectional data transfer using handshake mechanism with port c, and Port B can be used either Mode 0 or 1.
In this mode each line of port C(PC0-PC7) can SET/RESET by suitably loading the control word register.
Example
As an example, if it is needed that PC5 be set, then in the control word, Since it is BSR mode, D7 = '0'. Since D4, D5, D6 are not used, assume them to be '0'. PC5 has to be selected, hence, D3 = '1', D2 = '0', D1 = '1'. PC5 has to be set, hence, D0 = '1'. Thus, as per the above values, 0B (Hex) will be loaded into the Control Word Register (CWR).
I/O mode
Mode 0 input mode In the input mode, the 8255 gets data from the external peripheral ports and the MPU reads the received data via its data bus.
The MPU first selects the 8255 chip by making CS low. It then selects the desired port using A0 and A1 lines. The MPU then issues an RD signal to read the data from the external peripheral device via the system data bus.
Mode 0 - Output mode In the output mode, the MPU sends data to 8255 via system data bus and then the external peripheral ports receive this data via 8255 port.
MPU first selects the 8255 chip by making CS low. It then selects the desired port using A0 and A1 lines. MPU then issues a WR signal to write data to the selected port via the system data bus. This data is then received by the external peripheral device connected to the selected port.
this mode port A and B use 8-bit I/O data and port C uses two ports 4-bit data. The characteristics of mode 0 are:
Output
is latched. Input does not latched. Ports do not have the capability of handshake mode or interrupt mode.
Example :
Figure 9:
19
Solutions: Port Address : It is actually an I/O memory map. When A15 is active high, Chip Select signal is activated. Assuming all dont care signals are at logic 0, therefore ports address are as follows:
20
Solution:
Control Word:
21
Example: Write a BSR control word subroutine to set bit PC7 and PC3, and reset after 10ms. Use the schematic diagram as shown below.
22
Solution:
23
Solution:
Subroutine: Assuming that the delay subroutine has been determined earlier.
24
Example
Write a program to read the DIP switches and display the reading from port B at port A and from port CL at port CU. Consider Port A=80h (A1=0,A0=0) Port B=81H (A1=0,A0=1) Port C= 82H (A1=1,A0=0) Control register=83H (A1=1,A0=1).
Control word
D7=1, for I/O function D6,D5=00 PORT A in MODE 0 D4=0, Port A=OUTPUT D3=0,Port CU=OUTPUT D2=0, PORT B in mode 0 D1=1, port B=input D0=1,port CL=Input.
Programming code:
MVI A,83H; load accumulator with the control word OUT 83H; write the word in the control register to initialize the ports IN 81H; Read the switches at port B OUT 80H; Display the reading at port A IN 82H; Read switches at port C ANI 0FH; mask the upper four bits of port c. these bits are not input data RLC RLC RLC RLC OUT 82H, Display data at port CL HLT
Mode 1
This mode is same as mode 0 but only difference is port C is been used for handshaking and control. Two ports i.e. port A and Port B can be used as 8 bit i/o port Each port uses 3 lines of the port C as handshake signals and remaining two signals can be function as i/o port Interrupt logic is supported.
Strobe input(STB(AL)): This is generated by peripheral device to indicate that it has transmitted a byte of data. In response to STB, 8255 generates IBF and INTR signals IBF (Input Buffer Full): This indicate that input latch has received the data byte . It acknowledgement signal by 8255. INTR(Interrupt Request): This is an o/p signal that is used as interrupt to MPU. INTE( Interrupt Enable): This internal flip-flop , which is been used to enable or disable the generation of INTR signal.
Mode 1 Input
Input configuration
Output configuration
Output configuration
Find port addresses by analyzing the decode logic Determine the control word to setup port A as input and port B as output in mode1 Determine the BSR word to enable INTEa(port A) Determine the masking byte to verify the OBFb(AL) line in the status check I/O(PORT) Write initialization instructions and printer subroutine to output characters that are stored in memory
MVI A, DATA; load accumulator with data OUT FFH; output accumulator contents to port FFH HLT ; end the program
Mode 1 Input
Signal Description
STB- Strobe input: (active low) : generated by peripheral to indicate it has transmitted the data. IBF( Input buffer full) : Acknowledged by 8255 to indicate the input buffer has received the data. INTR( Interrupt Request) : This is output signal that is used to INTR the MPU. This is high when STB , IBF and INTE(internal signal) is high. INTE (Interrupt Enable): internal flip flop
This mode is used primarily in applications such as data transfer between two computers. In this mode, Port A can be configured as the bidirectional port and Port B either in Mode 0 or Mode 1.
Port A uses five signals from Port C as handshake signals for data transfer. The remaining three signals from port C can be used either as simple I/O or as handshake for port B.
Handshaking signals are provided to maintain proper bus flow discipline in a similar manner to MODE 1. Interrupt generation and enable/disable functions are also available.
Used in Group A only. One 8-bit, bi-directional bus port (Port A) and a 5-bit control port (Port C). Both inputs and outputs are latched.
Timing diagram is a combination of the Mode 1 Strobed Input and Mode 1 Strobed Output Timing diagrams.
INTR : Interrupt request is an output that requests an interrupt. ~OBF : Output Buffer Full is an output indicating that that output buffer contains data for the bidirectional bus. ~ACK : Acknowledge is an input that enables tri-state buffers which are otherwise in their high-impedance state. ~STB : The strobe input loads data into the port A latch.
IBF : Input buffer full is an output indicating that the input latch contains information for the external bi-directional bus. INTE : Interrupt enable are internal bits that enable the INTR pin. BIT PC6(INTE1) and PC4(INTE2). PC2,PC1,PC0 : These port C pins are generalpurpose I/O pins that are available for any purpose.
Write a program to initialize 8255 in the configuration given below: 1. Port A: Simple Input 2. Port B: Simple Output 3. Port CL: Output 4. Port CU: Input Assume address of the control word register of 8255 as 83H. Solution:
MVI A, 98H : Load control word (D7 = 1 for I/O, D6-D5 = 00 for mode 0 of group A, D4 =1 for port A as input, D3 = 1, for port C upper part as input, D2 = 0 for mode 0 of group B, D1 = 0 for port B as output, D0 = 0 for port C lower part as output.)
Write a program to initialize 8255 in the configuration given below: 1. Port A: Output with handshake 2. Port B: Input with handshake
Write a program to initialize 8255 in the configuration given below: 1. Port A: Output with handshake 2. Port B: Input with handshake
Interface an 8-digit 7 segment LED display using 8255 to the 8085 microprocessor system and write an 8085 assembly language routine to display message on the display.
port A and port B are used as simple latched output ports. Port A provides the segment data inputs to the display and port B provides a means of selecting a display position. A0-A7 lines are used to decode the addresses for 8255. For this circuit different addresses are: PA = 00H PB = 01H PC = 02H CR = 03H.
Source program: SOFTWARE TO INITIALIZE 8255: MVI A, 80H : Load control word in AL OUT CR : Load control word in CR SUBROUTINE TO DISPLAY MESSAGE ON MULTIPLEXED LED DISPLAY: SET UP REGISTERS FOR DISPLAY: MVI B, 08H : load count MVI C, 7FH : load select pattern (for selecting one of the digit) LXI H, 6000H : starting address of message DISPLAY MESSAGE: DISP 1: MOV A, C : select digit OUT PB MOV A, M : get data OUT PA : display data CALL DELAY : wait for some time MOV A, C : MOV A, C RRC (right rotate for selecting second digit) MOV C, A : adjust selection pattern INX H DCR B : Decrement count JNZ DISP 1 : repeat 8 times RET
CODE CONVERSION
Convert a 2-digit BCD number stored at memory address 2200H into its binary equivalent number and store the result in a memory location 2300H.
Flow chart:--
Convert a 2-digit BCD number stored at memory address 2200H into its binary equivalent number and store the result in a memory location 2300H. LDA 2200H : Get the BCD number Sample problem 1: MOV B, A : Save it (2200H) = 67H ANI OFH : Mask most significant four bits (2300H) = 6 x OAH + 7 = 3CH + 7 = MOV C, A : Save unpacked BCDI in C register 43H MOV A, B : Get BCD again ANI FOH : Mask least significant four bits RRC : Convert most significant four bits into unpacked BCD2 RRC RRC RRC MOV B, A : Save unpacked BCD2 in B register XRA A : Clear accumulator (sum = 0) MVI D, 0AH : Set D as a multiplier of 10 Sum: ADD D : Add 10 until (B) = 0 DCR B : Decrement BCD2 by one JNZ SUM : Is multiplication complete? i if not, go back and add again ADD C : Add BCD1 STA 2300H : Store the result HLT : Terminate program execution
Thank you.