Keyboard Interfacing With 8086 Using 8255 153.pdfl 👊

How to Interface a Keyboard with 8086 Microprocessor Using 8255 Programmable Peripheral Interface
In this article, you will learn how to interface a keyboard with 8086 microprocessor using 8255 programmable peripheral interface (PPI). Keyboard interfacing is a process of connecting a keyboard to a microprocessor and transferring the key codes from the keyboard to the microprocessor. Keyboard interfacing can be done in various modes, such as simple input-output mode, handshake mode, or bi-directional mode. In this article, we will focus on the simple input-output mode using 8255 PPI.
What is 8255 PPI?
8255 PPI is a general purpose programmable I/O device designed to interface the CPU with its outside world such as ADC, DAC, keyboard etc. It can be used with almost any microprocessor. It consists of three 8-bit bidirectional I/O ports i.e. PORT A, PORT B and PORT C. We can assign different ports as input or output functions.
How to Interface a Keyboard with 8086 Using 8255 PPI?
To interface a keyboard with 8086 using 8255 PPI, we need to connect the keyboard matrix to the ports of 8255 PPI. A keyboard matrix is a grid of switches that are arranged in rows and columns. Each switch corresponds to a key on the keyboard. When a key is pressed, it closes the switch and connects the corresponding row and column lines. The key code can be determined by scanning the row and column lines and identifying which switch is closed.
For example, let us consider a 4×4 keyboard matrix as shown below:
| C0 | C1 | C2 | C3 |
|----|----|----|----|
| R0 | 0 | 1 | 2 | 3 |
| R1 | 4 | 5 | 6 | 7 |
| R2 | 8 | 9 | A | B |
| R3 | C | D | E | F |
We can interface this keyboard matrix with 8086 using 8255 PPI as follows:
- Connect port A of 8255 PPI as output port for selecting a row of keys.
- Connect port B of 8255 PPI as input port for sensing a closed key.
- Connect port C of 8255 PPI as control port for setting the mode of operation.
- Connect the row lines R0-R3 to PA0-PA3 of port A.
- Connect the column lines C0-C3 to PB0-PB3 of port B.
- Connect CS’, RD’, WR’, A1 and A0 pins of 8255 PPI to the corresponding pins of the microprocessor.
How to Write an ALP for Detecting a Key Closure and Return the Key Code in AL?
To write an ALP for detecting a key closure and return the key code in AL, we need to follow these steps:
- Initialize the mode of operation of 8255 PPI by writing a suitable control word in the control register. The control word should set port A as output port, port B as input port, and port C as BSR mode. The control word should also set all ports in mode 0 (simple input-output mode). The control word can be written as:
10000010B. - Select a row of keys by sending a low signal to one of the PA0-PA3 pins of port A. For example, to select row R0, we can send
11111110Bto port A. - Read the data from port B and check if any of the PB0-PB3 pins are low. If yes, it means that a key in that row is pressed. For example, if we read
11111110Bfrom port B, it means that key0is pressed. - If no key is pressed, repeat steps 2 and 3 for other rows until a key closure is detected.
- If a key is pressed, return the key code in AL register by combining the row and column bits. For example, if row R0 and column C1 are low, then the key code is
0001B, which corresponds to key1. - The debouncing period for a key is 20 ms. This means that we need to wait for at least 20 ms before reading another key press. This can be done by using a delay loop or a timer interrupt.
The following is an example of an ALP for detecting a key closure and return the key code in AL:
MOV AL,82H ;select control register
MOV BL,10000010B ;control word
OUT AL,BL ;write control word
MOV AL,80H ;select port A
MOV BL,11111110B ;select row R0
OUT AL,BL ;write to port A
MOV AL,81H ;select port B
IN BL,AL ;read from port B
AND BL,FH ;mask upper bits
CMP BL,FH ;compare with FFH
JZ NEXTROW ;if equal jump to next row
MOV CL,BL ;save column bits in CL
MOV BL,FH ;set row bits in BL
SHR BL,4 ;shift right by four bits
OR BL,CL ;combine row and column bits
MOV AL,BL ;move key code to AL
JMP END ;end program
NEXTROW: MOV AL,80H ;select port A
MOV BL,11111101B ;select row R1
OUT AL,BL ;write to port A
;repeat steps similar to above for other rows
END: HLT ;halt program
Advantages of Keyboard Interfacing with 8086 Using 8255 PPI
Keyboard interfacing with 8086 using 8255 PPI has some advantages over other methods of keyboard interfacing. Some of these advantages are:
- It is simple and easy to implement, as it requires only one 8255 PPI chip and a few connections.
- It is flexible and versatile, as it allows the programmer to choose any port of 8255 PPI as input or output port, and to select any row or column of the keyboard matrix.
- It is compatible and universal, as it can be used with almost any microprocessor and any keyboard matrix size.
- It is economical and efficient, as it reduces the hardware cost and complexity, and improves the performance and speed of the system.
Disadvantages of Keyboard Interfacing with 8086 Using 8255 PPI
Keyboard interfacing with 8086 using 8255 PPI also has some disadvantages over other methods of keyboard interfacing. Some of these disadvantages are:
- It is not suitable for large keyboard matrices, as it requires more ports of 8255 PPI and more scanning time.
- It is not reliable and secure, as it may cause errors or glitches due to noise or interference in the row and column lines.
- It is not advanced and sophisticated, as it does not support multiple key presses, interrupt handling, or bi-directional data transfer.
Comparison of Keyboard Interfacing with 8086 Using 8255 PPI with Other Methods
There are other methods of keyboard interfacing besides using 8255 PPI. Some of these methods are:
- Using direct I/O ports of the microprocessor. This method requires the microprocessor to have enough I/O ports to connect to the keyboard matrix. This method is simple and fast, but it consumes a lot of I/O ports and may not be feasible for large keyboard matrices.
- Using serial communication protocols such as UART, SPI, or I2C. This method requires the keyboard to have a built-in controller that can communicate with the microprocessor using serial data transfer. This method is efficient and reliable, but it requires additional hardware and software components and may not be compatible with all keyboards.
- Using dedicated keyboard controllers such as 8279. This method requires a special IC that can interface the keyboard with the microprocessor and provide features such as scanning, decoding, buffering, and interrupt handling. This method is advanced and sophisticated, but it requires an extra IC and may not support all keyboard modes.
The following table summarizes the comparison of keyboard interfacing with 8086 using 8255 PPI with other methods:
| Method | Advantages | Disadvantages |
|---|---|---|
| Using direct I/O ports | Simple and fast | Consumes a lot of I/O ports |
| Using serial communication protocols | Efficient and reliable | Requires additional hardware and software components |
| Using dedicated keyboard controllers | Advanced and sophisticated | Requires an extra IC |
| Using 8255 PPI | Simple, flexible, versatile, compatible, economical, and efficient | Not suitable for large keyboard matrices, not reliable and secure, not advanced and sophisticated |
Explanation of UART, SPI, and I2C
UART, SPI, and I2C are three common serial communication protocols that are used in microcontroller development. Each protocol has its own features, advantages, and disadvantages. Here is a brief explanation of each protocol:
UART
UART stands for Universal Asynchronous Receiver/Transmitter. It is a physical circuit or standalone IC in a microcontroller, not a communication protocol like SPI or I2C. UART’s primary function is to send and receive serial data. UART supports bi-directional, asynchronous, and serial data transmission. It has two data lines, one to transmit (TX) and another to receive (RX), which are used to communicate between two devices. UART can operate in simplex, half-duplex, or full-duplex mode. UART does not have a clock signal, so it relies on start and stop bits to synchronize the data transfer. UART also uses a parity bit to check for errors. UART can have different baud rates, which are the number of bits per second that are transmitted or received. Both devices must have the same baud rate to communicate properly. UART is ideal for low power, long distance communication between two devices. UART is commonly used for debugging, data logging, wireless communication, etc.
SPI
SPI stands for Serial Peripheral Interface. It is a synchronous serial communication protocol that allows one master device and one or more slave devices to communicate with each other. SPI uses four wires: MISO (Master In Slave Out), MOSI (Master Out Slave In), SCK (Serial Clock), and SS (Slave Select). The master device initiates and controls the data transfer by generating the clock signal and selecting the slave device. The master and slave devices exchange data simultaneously by shifting bits on the MISO and MOSI lines. SPI can operate in full-duplex mode only. SPI has no start and stop bits, parity bits, or addressing scheme. SPI can have different clock frequencies, which determine the speed of data transfer. The master device can adjust the clock frequency according to the slave device’s capability. SPI is best for high speed, low latency communication between one master and one or few slaves. SPI is commonly used for sensors, memory cards, display modules, etc.
I2C
I2C stands for Inter-Integrated Circuit. It is a synchronous serial communication protocol that allows multiple master devices and multiple slave devices to communicate with each other on a shared bus. I2C uses two wires: SDA (Serial Data) and SCL (Serial Clock). The master device initiates and controls the data transfer by generating the clock signal and sending the address of the slave device. The slave device acknowledges the address and sends or receives data on the SDA line. I2C can operate in half-duplex mode only. I2C has start and stop bits to indicate the beginning and end of a data transfer. I2C also has an acknowledgment bit to confirm the reception of data. I2C uses a 7-bit or 10-bit addressing scheme to identify the slave devices on the bus. I2C can have different clock frequencies, which determine the speed of data transfer. The master device can adjust the clock frequency according to the bus conditions and the slave device’s capability. I2C is ideal for moderate speed communication with addressable devices and a scalable bus that can support multiple masters and slaves. I2C is commonly used for sensors, EEPROMs, RTCs, etc.
Conclusion
In this article, we have discussed the keyboard interfacing with 8086 using 8255 PPI, which is one of the methods of connecting a keyboard to a microprocessor and transferring the key codes from the keyboard to the microprocessor. We have explained the working principle, the working protocol, the advantages and disadvantages, and the applications of this method. We have also compared this method with other methods of keyboard interfacing, such as using direct I/O ports, using serial communication protocols, and using dedicated keyboard controllers. We have also explained the UART, SPI, and I2C protocols, which are three common serial communication protocols that are used in microcontroller development. We have described their features, advantages, disadvantages, and uses. We hope that this article has helped you to understand the keyboard interfacing with 8086 using 8255 PPI and the UART, SPI, and I2C protocols better.
https://github.com/9fragad0mixsu/Final2x/blob/main/src/Create%20Your%20Own%20Logo%20with%20Xxii%20Daemon%20Font%20and%20Doubletwo%20Studios.md
https://github.com/3creditZlinu/nhost/blob/main/observability/Mahabharat%202013%20All%20Episodes%20Free%20240%20Enjoy%20the%20Ancient%20Indian%20Epic%20on%20Your%20Device.md
https://github.com/buecol0gnosbi/jruby-rack/blob/master/src/Il%20Bambino%20Col%20Pigiama%20A%20Righe%20Film%20Completo%20Come%20Scaricare%20La%20Colonna%20Sonora%20Originale%20Del%20Film.md
https://github.com/noricola/gpt-migrate/blob/main/gpt_migrate/memory/Scaricare%20giochi%20per%20psp%20gratis%20download%20le%20soluzioni%20ai%20problemi%20pi%20comuni.md
https://github.com/congmitii/wild-wild-path/blob/main/src/Intelliscore%20Ensemble%207.0%20Portable%20Convert%20Any%20Music%20File%20into%20MIDI.md
https://github.com/pieginOnai/laravel-dusk-select2/blob/master/.circleci/Jillian%20Michaels%20Killer%20Abs%20Torrent%20Download%20Hit%2013%20The%20Most%20Effective%20Ab%20Workout%20Ever.md
https://github.com/thruskomali/aider/blob/main/_layouts/xhciroothub0drivergigabyte%20Download%20and%20Update%20the%20Latest%20USB%20Root%20Hub%20(xHCI)%20Driver%20for%20Your%20Gigabyte%20PC.md
https://github.com/mictechace/unitybuildbadgeservice/blob/master/UnityBuildBadge/Models/Neuropsicologa%20Humana.pdf%20[5143oo5ve94j]%20-%20Documents%20and%20E-books[3].md
https://github.com/1ininPpronha/platformio-atom-ide-terminal/blob/master/keymaps/Algodoo%202.0.0%20Crack%201%20Enjoy%20the%20Fun%20and%20Creativity%20of%20Simulating%20Physics%20with%20This%20Hack.md
https://github.com/bibmaWopna/chatglm.cpp/blob/main/examples/Download%20free%20neufert%20time%20saver%20standards%20pdf%20Learn%20from%20the%20best%20practices%20of%20Ernst%20and%20Peter%20Neufert.md
86646a7979