Digital Signal Processing Reference
In-Depth Information
computer and keyboard. The keyboard and the system can exchange several
commands and messages as seen in Tables 11.1 and 11.2.
Table 11.2 PS/2 Commands and messages sent by keyboard.
Messages Sent by Keyboard
Hex Value
Resend Message
FE
Two bad messages in a row
FC
Keyboard Acknowledge Command
FA
Sent by Keyboard after each command byte
Response to Echo command
EE
Keyboard passed selftest
AA
Keyboard buffer overflow
00
11.2 Keyboard Scan Codes
Keyboards are normally encoded by placing the key switches in a matrix of
rows and columns. All rows and columns are periodically checked by the
keyboard encoder or "scanned" at a high rate to find any key state changes. Key
data is passed serially to the computer from the keyboard using what is known
as a scan code. Each keyboard key has a unique scan code based on the key
switch matrix row and column address to identify the key pressed.
There are different varieties of scan codes available to use depending on the
type of keyboard used. The PS/2 keyboard has two sets of scan codes. The
default scan code set is used upon power on unless the computer system sends a
command the keyboard to use an alternate set. The typical PC sends commands
to the keyboard on power up and it uses an alternate scan code set. To interface
the keyboard to the FPGA board, it is simpler to use the default scan code set
since no initialization commands are required.
11.3 Make and Break Codes
The keyboard scan codes consist of 'Make' and 'Break' codes. One make code
is sent every time a key is pressed. When a key is released, a break code is sent.
For most keys, the break code is a data stream of F0 followed by the make code
for the key. Be aware that when typing, it is common to hit the next key(s)
before releasing the first key hit.
Using this configuration, the system can tell whether or not the key has been
pressed, and if more than one key is being held down, it can also distinguish
which key has been released. One example of this is when a shift key is held
down. While it is held down, the '3' key should return the value for the '#'
symbol instead of the value for the '3' symbol. Also note that if a key is held
down, the make code is continuously sent via the typematic rate until it is
released, at which time the break code is sent.
Search WWH ::




Custom Search