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.
HARDWARE FOR MATRIX KEYBOARD INTERFACE
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.
INTERFACING SCHEME
SOFTWARE FOR MATRIX KEYBOARD INTERFACE
As port A is used as an output port, control word for 8255 is 80H.
| 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
Delay Subroutine: - Delay: LXI D, Count
- Back: DCX D
- MOV A, D
- ORA E
- JNZ Back
- RET
| Flowchart for Source Program _thumb.gif) Delay Routine _thumb.gif) |
Related Programs (Click down)
2-Digit BCD to binary conversion.
Binary to BCD conversion
Find the 7-segment codes for given numbers
Find the ASCII character