top of page

Groupe de nature-et-conscience

Public·22 membres

Keyboard Interfacing with 8086 Using 8255 PPI: Concepts, Circuit Diagram, Program, and Applications


Keyboard Interfacing with 8086 Using 8255




Have you ever wondered how your computer keyboard communicates with the processor? How does the processor know which key you pressed and what action to perform? In this article, we will explore the concept of keyboard interfacing with 8086 microprocessor using 8255 programmable peripheral interface (PPI). We will learn about the basics of keyboard interfacing, the components involved, the modes of operation of 8255 PPI, the circuit diagram, the program, and the advantages and applications of this technique.




Keyboard Interfacing With 8086 Using 8255 153.pdfl



Introduction




Before we dive into the details of keyboard interfacing with 8086 using 8255, let us first understand some basic terms and concepts.


What is keyboard interfacing?




Keyboard interfacing is a process of connecting a keyboard to a microprocessor or a microcontroller and enabling them to exchange data. The keyboard acts as an input device that sends signals to the processor when a key is pressed or released. The processor then interprets these signals and performs the corresponding action. For example, when you press the letter 'A' on your keyboard, the keyboard sends a code to the processor that identifies the key as 'A'. The processor then displays 'A' on your screen or performs some other function depending on the program.


What is 8086 microprocessor?




The 8086 microprocessor is a 16-bit processor that was introduced by Intel in 1978. It is one of the first processors to use the x86 instruction set architecture, which is still widely used today. The 8086 microprocessor has a data bus width of 16 bits, an address bus width of 20 bits, and can operate at a clock speed of up to 10 MHz. It can execute up to two instructions per clock cycle and has a total of 229 instructions. The 8086 microprocessor can address up to 1 MB of memory and has eight general-purpose registers, four segment registers, a flag register, an instruction pointer, and a stack pointer.


What is 8255 PPI?




The 8255 PPI is a general-purpose programmable input/output device that was designed by Intel in 1976. It can interface the CPU with various external devices such as keyboards, printers, displays, ADCs, DACs, etc. The 8255 PPI has three 8-bit bidirectional ports: port A, port B, and port C. Each port can be configured as an input or an output port depending on the mode of operation. The port C can also be divided into two 4-bit ports: port C upper and port C lower. The mode of operation of each port can be controlled by writing a suitable word in the control register. The control word specifies which ports are input or output, which ports are in which mode, and which ports are in bit set/reset mode. The 8255 PPI has 40 pins and operates in +5V regulated power supply. It can be used with almost any microprocessor and can support multiple modes of operation for each port.


Modes of Operation of 8255 PPI




The 8255 PPI can operate in two main modes: bit set/reset mode and input/output mode. The bit set/reset mode is used to set or reset individual bits of port C without affecting the other bits. The input/output mode is used to transfer data between the CPU and the external devices through the ports. The input/output mode is further divided into three sub-modes: mode 0, mode 1, and mode 2. Let us discuss each mode in detail.


Mode 0: Simple Input/Output




In this mode, all the three ports (port A, port B, and port C) can work as simple input or output ports. There is no handshake or interrupt mechanism in this mode. The data transfer is initiated by the CPU by reading or writing to the ports. The direction of each port can be specified by the control word. For example, if port A is configured as an output port and port B is configured as an input port, then the CPU can write data to port A and read data from port B. The port C can also be used as an input or output port, or it can be divided into two 4-bit ports and used for different purposes.


Mode 1: Handshake Input/Output




In this mode, either port A or port B can work as a simple input or output port, and the corresponding four bits of port C are used for handshake signals. The handshake signals are used to synchronize the data transfer between the CPU and the external device. The external device can send a signal to the CPU to indicate that it is ready to send or receive data, and the CPU can send a signal to the external device to acknowledge that it has received or sent data. This mode also supports interrupt handling and latching of input and output data. For example, if port A is configured as an output port and port B is configured as an input port, then the upper four bits of port C (PC7-PC4) are used for handshake signals for port A, and the lower four bits of port C (PC3-PC0) are used for handshake signals for port B.


Mode 2: Bidirectional Data Bus




In this mode, only port A works as a bidirectional data bus, and six bits of port C are used for handshake signals. The bidirectional data bus means that port A can act as both an input and an output port depending on the direction of data transfer. The direction of data transfer is controlled by the handshake signals. This mode also supports interrupt handling and latching of input and output data. For example, if port A is configured as a bidirectional data bus, then PC7-PC2 are used for handshake signals for port A, and PC1-PC0 are not used.


Keyboard Encoder and Decoder




To interface a keyboard with a microprocessor, we need two components: a keyboard encoder and a keyboard decoder. A keyboard encoder is a device that converts the key press or release into a binary code that can be transmitted to the microprocessor. A keyboard decoder is a device that converts the binary code received from the microprocessor into a signal that can activate the corresponding key on the keyboard.


Types of Keyboard Encoders




There are two types of keyboard encoders: contact type and contactless type. Contact type keyboard encoders use mechanical switches or contacts to detect the key press or release. Contactless type keyboard encoders use optical or magnetic sensors to detect the key press or release. Contact type keyboard encoders are cheaper and simpler than contactless type keyboard encoders, but they are prone to wear and tear, noise, and bouncing effects. Contactless type keyboard encoders are more reliable and accurate than contact type keyboard encoders, but they are more expensive and complex.


Types of Keyboard Decoders




There are two types of keyboard decoders: matrix type and serial type. Matrix type keyboard decoders use a matrix of rows and columns to identify each key on the keyboard. Serial type keyboard decoders use a serial communication protocol such as UART or SPI to communicate with each key on the keyboard. Matrix type keyboard decoders are simpler and cheaper than serial type keyboard decoders, but they require more pins and wires to connect with the microprocessor. Serial type keyboard decoders are more compact and efficient than matrix type keyboard decoders, but they require more logic and programming to implement.


Circuit Diagram of Keyboard Interfacing with 8086 Using 8255




To interface a keyboard with 8086 microprocessor using 8255 PPI, we need to connect the keyboard encoder output to one of the ports of the 8255 PPI, and connect the 8255 PPI to the data and address bus of the 8086 microprocessor. We also need to provide appropriate control signals to the 8255 PPI and the keyboard encoder. The following figure shows a possible circuit diagram of keyboard interfacing with 8086 using 8255.


![Circuit Diagram](https://www.eeeguide.com/wp-content/uploads/2018/02/8255-Interfacing-with-8086.png) The circuit diagram consists of the following components:



  • A keyboard encoder that converts the key press or release into a binary code. In this example, we use a contact type keyboard encoder that has 8 output lines (KB0-KB7) and 8 input lines (K0-K7). The output lines are connected to port A of the 8255 PPI, and the input lines are connected to a matrix of switches that represent the keys on the keyboard. The keyboard encoder also has a strobe output (STB) that indicates when a valid code is available on the output lines. The strobe output is connected to PC0 of the 8255 PPI.



  • An 8086 microprocessor that acts as the CPU of the system. It has 16 data lines (D0-D15) and 20 address lines (A0-A19). The data lines are connected to port B and port C lower of the 8255 PPI, and the address lines are connected to an address decoder that generates the chip select signal (CS) for the 8255 PPI. The address decoder also generates two other signals: A0 and A1, which are used to select one of the four registers of the 8255 PPI: port A, port B, port C, or control register. The 8086 microprocessor also has control signals such as read (RD), write (WR), and reset (RESET) that are connected to the corresponding pins of the 8255 PPI.



  • An 8255 PPI that acts as an interface between the keyboard encoder and the 8086 microprocessor. It has three ports: port A, port B, and port C. Port A is configured as an input port and connected to the output lines of the keyboard encoder. Port B is configured as an output port and connected to the data lines of the 8086 microprocessor. Port C is divided into two parts: port C upper and port C lower. Port C upper is configured as an output port and connected to the higher four data lines of the 8086 microprocessor. Port C lower is configured as an input port and connected to PC0 of the keyboard encoder and PC1-PC3 of some external devices such as LEDs or buzzers. The control register of the 8255 PPI is used to specify the mode of operation and direction of each port.



The circuit diagram works as follows:



  • When a key is pressed on the keyboard, a binary code corresponding to that key is generated by the keyboard encoder and sent to port A of the 8255 PPI. The keyboard encoder also sends a strobe signal to PC0 of the 8255 PPI to indicate that a valid code is available.



  • The 8086 microprocessor periodically polls PC0 of the 8255 PPI by reading from port C using an input instruction. If PC0 is high, it means that a key has been pressed and a code is ready on port A.



  • The 8086 microprocessor then reads from port A using another input instruction and obtains the binary code of the pressed key. It can then perform some action based on that code, such as displaying it on a screen or storing it in a memory.



  • The 8086 microprocessor can also write data or control words to port B or port C upper using output instructions. For example, it can write data to port B to send it to some external device such as a printer or a display. It can also write control words to port C upper to activate some external devices such as LEDs or buzzers.



  • The 8086 microprocessor can also write a control word to the control register of the 8255 PPI to change the mode of operation or direction of any port. For example, it can change port A from input to output mode, or port C lower from input to output mode.



Program for Keyboard Interfacing with 8086 Using 8255




To write a program for keyboard interfacing with 8086 using 8255, we need to follow some steps:



  • Initialize the 8255 PPI by writing a control word to the control register. The control word specifies the mode and direction of each port. In this example, we use the following control word: 10011010B. This means that port A is in input mode, port B is in output mode, port C upper is in output mode, port C lower is in input mode, and all ports are in mode 0 (simple input/output).



  • Poll PC0 of the 8255 PPI by reading from port C using an input instruction. If PC0 is high, it means that a key has been pressed and a code is ready on port A.



  • Read from port A using another input instruction and obtain the binary code of the pressed key. Store it in a register or a memory location.



  • Perform some action based on the code, such as displaying it on a screen or storing it in a memory.



  • Write data or control words to port B or port C upper using output instructions. For example, write data to port B to send it to some external device such as a printer or a display. Write control words to port C upper to activate some external devices such as LEDs or buzzers.



  • Repeat steps 2 to 5 until the program ends or a specific key is pressed.



The following is a possible assembly language code for keyboard interfacing with 8086 using 8255:



;Assume that the base address of the 8255 PPI is 80H ;Assume that the address of the control register is 83H ;Assume that the address of port A is 80H ;Assume that the address of port B is 81H ;Assume that the address of port C is 82H ORG 1000H ;Start of the program MOV AL,9AH ;Load the control word in AL OUT 83H,AL ;Write the control word to the control register LOOP: IN AL,82H ;Read from port C AND AL,01H ;Mask all bits except PC0 JZ LOOP ;If PC0 is zero, no key is pressed, go back to loop IN AL,80H ;If PC0 is one, read from port A MOV BL,AL ;Store the code in BL ;Perform some action based on BL ;Write data or control words to port B or port C upper if needed JMP LOOP ;Go back to loop END ;End of the program


Advantages and Applications of Keyboard Interfacing with 8086 Using 8255




Keyboard interfacing with 8086 using 8255 has some advantages and applications, such as:


Versatility and Flexibility




The 8255 PPI can be programmed to operate in different modes and directions for each port, which makes it a versatile and flexible component for interfacing various external devices with the microprocessor. It can also be used with almost any microprocessor and can support multiple modes of operation for each port.


User Interaction and Data Entry




The keyboard interfacing with 8086 using 8255 allows the user to interact with the microprocessor system and enter data through the keyboard. The keyboard can be used as an input device for various applications such as word processing, gaming, calculator, etc. The microprocessor can also display feedback or results on a screen or other output devices connected through the ports of the 8255 PPI.


Conclusion




In this article, we have learned about keyboard interfacing with 8086 using 8255. We have covered the basics of keyboard interfacing, the components involved, the modes of operation of 8255 PPI, the circuit diagram, the program, and the advantages and applications of this technique. We have also seen how to use markdown elements and HTML formatting to write an engaging and informative article. We hope you have enjoyed reading this article and learned something new.


Frequently Asked Questions




Here are some frequently asked questions about keyboard interfacing with 8086 using 8255:



  • Q: What is the difference between memory mapped I/O and I/O mapped I/O?



  • A: Memory mapped I/O and I/O mapped I/O are two techniques of interfacing external devices with the microprocessor. In memory mapped I/O, the external devices are assigned memory addresses and are accessed using the same instructions and control signals as those of memory. In I/O mapped I/O, the external devices are assigned separate I/O addresses and are accessed using special instructions and control signals. Memory mapped I/O has the advantage of using a larger address space and simpler programming, but it has the disadvantage of reducing the available memory space and increasing the access time. I/O mapped I/O has the advantage of saving the memory space and reducing the access time, but it has the disadvantage of using a smaller address space and requiring more instructions.



  • Q: How can we change the mode of operation of 8255 PPI?



  • A: We can change the mode of operation of 8255 PPI by writing a suitable control word to the control register. The control word specifies which ports are input or output, which ports are in which mode, and which ports are in bit set/reset mode. The control word has the following format:



![Control Word](https://www.geeksforgeeks.org/wp-content/uploads/8255-control-word.png)


  • Q: How can we interface a matrix keyboard with 8086 using 8255?



  • A: A matrix keyboard is a type of keyboard that uses a matrix of rows and columns to identify each key. To interface a matrix keyboard with 8086 using 8255, we need to connect the rows of the matrix keyboard to port A of the 8255 PPI, and connect the columns of the matrix keyboard to port B of the 8255 PPI. We also need to configure port A as an output port and port B as an input port in mode 0. The following steps describe the algorithm for interfacing a matrix keyboard with 8086 using 8255:




  • Initialize the 8255 PPI by writing a control word to the control register.



  • Write a data word to port A to activate one row of the matrix keyboard.



  • Read from port B to check if any key in that row is pressed.



  • If yes, identify the key by using a lookup table or a decoding logic.



  • If no, repeat steps 2 to 4 for each row until a key is pressed.



  • Perform some action based on the pressed key.



  • Repeat steps 2 to 6 until the program ends or a specific key is pressed.




  • Q: How can we interface an LED display with 8086 using 8255?



  • A: An LED display is a type of display that uses light-emitting diodes (LEDs) to show alphanumeric characters or symbols. To interface an LED display with 8086 using 8255, we need to connect the data lines of the LED display to port B of the 8255 PPI, and connect the segment select lines of the LED display to port C upper of the 8255 PPI. We also need to configure port B as an output port and port C upper as an output port in mode 0. The following steps describe the algorithm for interfacing an LED display with 8086 using 8255:




  • Initialize the 8255 PPI by writing a control word to the control register.



  • Write a data word to port B to specify which segments of the LED display should be turned on or off.



  • Write a data word to port C upper to specify which segment of the LED display should be selected.



  • Repeat steps 2 and 3 for each segment until all segments are displayed.



  • Q: What are the advantages and applications of keyboard interfacing with 8086 using 8255?



  • A: Keyboard interfacing with 8086 using 8255 has some advantages and applications, such as:



Versatility and Flexibility




The 8255 PPI can be programmed to operate in different modes and directions for each port, which makes it a versatile and flexible component for interfacing various external devices with the microprocessor. It can also be used with almost any microprocessor and can support multiple modes of operation for each port.


User Interaction and Data Entry




The keyboard interfacing with 8086 using 8255 allows the user to interact with the microprocessor system and enter data through the keyboard. The keyboard can be used as an input device for various applications such as word processing, gaming, calculator, etc. The microprocessor can also display feedback or results on a screen or other output devices connected through the ports of the 8255 PPI.


Traffic Light Control




The keyboard interfacing with 8086 using 8255 can be used to control the traffic lights at a junction. The keyboard can be


À propos

Bienvenue dans le groupe ! Vous pouvez communiquer avec d'au...
bottom of page