Keyboard Interfacing with 8255
Keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and columns through ports. Therefore, with two 8-bit ports, an 8 x 8 matrix of keys can be connected to a microprocessor. When a key is pressed, a row and column make a contact. Otherwise, there is no connection between rows and columns. A 4 x 4 matrix connected to two ports. The rows are connected to an output port and the columns are connected to an input port. Getting meaningful data from a keyboard requires three major tasks: Detect a keypress Debounce the keypress Encode the keypress ( produce a standard code for the pressed key) Logic “0” is read by the microprocessor when the key is pressed. Whenever a mechanical push-button is pressed or released once, the mechanical components of the key do not change the position smoothly, rather it generates a transient response. These may be interpreted as the multiple pressures and responded accordingly. The rows of the matrix are connected to four output lines and columns are connected to four input port lines. When no keys are pressed, the column lines are held high by the pull-up resistors connected to + 5V. Pressing a key connects a row and a column. To detect if any key is pressed is to output 0 to all rows and then check column to see if a pressed key has connected a low (zero) to a column. Once the columns are found to be all high, the program enters another loop, which waits until a low appears on one of the columns i.e. indicating a key press. A simple 20 / 10 msec delay is executed to debounce task. After the debounce time, another check is made to see if the key is still pressed. And the initial detection was caused by a noise pulse. The final task is to determine the row and column of the pressed key and convert information to Hex-code for the pressed key. The 4-bit code from I/P port and the 4-bit code from O/P port ( row & column) are converted to hex code. To avoid this problem, two schemes are suggested. Use of bistable multivibrator at the output of the key to debounce it. The microprocessor has to wait for the transient period ( atleast for 10 ms), so that, the transient response, settles down, and reaches a steady state. If any of the columns are low now, then the assumption is made that, it was a valid key press. The final task is to determine the row and column of the pressed key and convert this information to Hex-code for the pressed key. The 4-bit code from I/P port and the 4-bit code from O/P port ( row and column) are converted to Hex-code.
Download
0 formatsNo download links available.