The
Keyboard
The
keyboard is interfaced
to
the system through one pair of lines connected
to
the
odd-addressed 8520 CIA chip. These lines are CNT, for the keyboard clock (input from
keyboard), and SP, for keyboard
data
(input or output).
HOW
THE
KEYBOARD
DATA
IS
RECEIVED
The
CNT
line is used as a clock for the keyboard. On each transition of this line, one
bit
of
data
is clocked in from the keyboard. The keyboard sends this clock when each
data
bit
that
is
to
be sent is stable on the SP line.
The
clock is an active
low
pulse.
The
rising edge of this pulse clocks
in
the data.
The
8520 is set up
to
use the CNT line as a clock and the SP line as a
data
input to an
internal serial shift register. Appendix F contains most of the
data
sheet for the 8520
and provides more information for interested parties.
After a
data
byte has been received from the keyboard, an interrupt (from the
8520)
is
issued to the processor.
The
keyboard waits for a handshake signal from the system
before transmitting any more keystrokes. (The handshake is issued by the processor
pulsing the SP line low for a minimum of
75
microseconds.)
If
another keystroke is received before the previous one has been accepted by the proces-
sor, the keyboard-processor (internal
to
keyboard) holds a type-ahead buffer
apprOXI-
mately 10 "keycodes" long. (Keycodes are explained in the next section).
TYPE
OF
DATA
RECEIVED
The
keyboard
data
is
not received
in
the form of ASCII characters. Instead, for max-
imum versatility,
it
is
received
in
the form of keycodes. These codes include not only
the down-transition of the key,
but
also the up-transition. This allows your software to
use both sets of information
to
determine exactly what is happening on the keyboard.
Here
is
a list of the hexadecimal values
that
are assigned to the keyboard. A downstroke
of the key transmits the value shown here. An upstroke of the key transmits this value
plus $80.
The
picture of the keyboard
at
the end of this section shows the positions
that
correspond to the description
in
the paragraphs below.
236
Interface Hardware