Statement: Interface a 64-key matrix keyboard to the 8085 microprocessor using 8255. Write an 8085 assembly language program to initialize 8255 and to read the key code.
Home
8085 Forum
8085 Free Projects
8085 Free Programs
8085 Tutorials
8085 details
Interfacing Techniques
Electronic Tutorials
Electronic Projects
Assembler/ IDE
Datasheets
Guest Book
About Me


Source program

       MVI A, 90H                        : Initialize Port A as input and
       OUT CR                        : Port B as Output
START: MVI A, 00                        : Make all scan lines zero
       OUT PB
BACK: IN PA
       CPI FF                                : Check for key release
       JNZ BACK                        : If not, wait for key release
       CALL DELAY                        : Wait for key debounce
BACK 1: IN PA
       CPI FF                                : Check for key press
       JZ BACK 1                        : If not, wait for key press
       CALL DELAY                        : Wait for key debounce
       MVI L, 00H                        : Initialize key counter
       MVI C, 08H
       MVI B, FEH                        : Make one column low
NEXTCOL: MOV A, B
       OUT PB
       MVI D, 08H                        : Initialize row counter
        IN PA                                : Read return line status
NEXTROW: RRC                        : Check for one row
       JNC DISPLAY                        : If zero, goto display else continue
       INR L                                : Increment key counter
        DCR D                        : Decrement row counter
       JNZ NEXTROW                : Check for next row
       MOV A, B
       RLC                                : Select the next column
       MOV B, A
       DCR C                                : Decrement column count
       JNZ NEXTCOL                        : Check for last column if not repeat
       JMP START                        : Go to start

INTERFACING SCHEME




Delay subroutine:

Delay: LXI D, Count
Back: DCX D                        
       MOV A, D        
       ORA E                
       JNZ Back                
       RET

Fig. shows a matrix keyboard with 64 keys connected to the 8085 microprocessor using 8255. A matrix keyboard reduces the number of connections, thus the number of interfacing lines. In this example, the keyboard with 64 keys, is arranged in 8 x 8 (8 rows and 8 columns) matrix. This requires sixteen lines from the microprocessor to make all the connections instead of 64 lines if the keys are connected individually. The interfacing of matrix keyboard requires two ports: one input port and other output port. Rows are connected to the input port, port A and columns are connected to the output port, port B.


HARDWARE FOR MATRIX KEYBOARD INTERFACE
SOFTWARE FOR MATRIX KEYBOARD INTERFACE



FLOWCHART




Source Program
Delay routine