Commodore Amiga Hardware Reference Manual page 303

Hide thumbs Also See for Amiga:
Table of Contents

Advertisement

KEYBOARD INTERFACE
The
keyboard plugs into the computer via a four-conductor cable similar
to a telephone handset coily cord (in fact, a telephone handset cable
may be substituted in a pinch).
The four wires provide 5-volt power,
ground, and two signals called KCLK (keyboard clock) and KDAT (keyboard
data).
KCLK is unidirectional and always driven by the keyboard;
KDAT is driven by both the keyboard and the collputer.
Both signals
are open-collector; there are pullup resistors in both the keyboard
(inside the keyboard microprocessor) and the collputer.
Keyboard communications:
The
keyboard transmits 8-bit data words serially to the
main unit.
Before the transmission starts, both KCLK and KDAT
are high.
The
keyboard starts the transmission by putting out
the first data bit (on KDAT), followed by a pulse on KCLK (low
then high); then it puts out the second data bit and pulses
KCLK until all eight data bits have
been
sent.
After the
end of the last KCLK pulse, the keyboard pulls KDAT high again.
When the cOllputer has received the eighth bit, it must pulse
KDAT low for at least 75 microseconds, as a handshake signal
to the keyboard.
All codes transmitted to the collputer are rotated one bit before
transmission.
The transmitted order is therefore 6-5-4-3-2-1-0-7.
The reason for this is to transmit the up/down flag last, in
order to cause a key-up code to be transmitted in case the keyboard
is forced to restore lost sync (explained in more detail below) •
The KDAT line is active low; that is, a high level (+5V) is
interpreted as 0, and a low level (OV) is interpreted as
1.
KCLK
- - V - V - V - V - V - V - V - V
KDAT
(6)
(5)
First
sent
(4)
(3)
(2)
(1)
(0)
(7)
Last
sent
The
keyboard processor sets the KDAT line about 20 microseconds
before it pulls KCLK low.
KCLK stays low for about 20 microseconds,
then
goes high again.
The
processor waits another 20 microseconds
before changing KDAT.
Therefore, the bit rate during transmission is about 60 microseconds
per bit, or 17 kbits/sec.
Keycodes:
Each key has a keycode associated with it (see accollpanying
table).
Keycodes are always 7 bits long.
The
eighth bit is a
"key-up"/"key-down" flag; a 0 (high level) means that the key
was pushed down, and a 1 (low level) means the key was released
(the CAPS LOCK key is different -- see below) •
For exanple, here is a diagram of the "B" key being pushed down.
The
keycode for "B" is 35H
=
00110101; due to the rotation of
the byte, the bits transmitted are 01101010.
KCLK
- - V - V - V - V - V - V - V - V
KDAT
,
,--\...--..1--'--1
0 1 1
0
1
0
1
0
In the next exanple, the "B" key is released.
The
keycode
is still 35H, except that bit 7 is set to indicate "key-up,"
resulting in a code of BSH
=
10110101.
After rotating, the
transmission will be 01101011:
KCLK
- - V - V - V - V
V - V - V - V
KDAT
,
'--\...--..1--,
,
0 1 1
0
1
0 1 1
CAPS LOCK key:
This key is different from all the others in that it
generates a keycode only when it is pushed down, never
when
it
is released.
However, the up/down bit is still used.
When
pushing the CAPS LOCK key turns on the CAPS LOCK LED, the
up/down bit will be 0; when pushing CAPS LOCK shuts off the LED,
the up/down bit will be 1.
"Out-of sync" condition:
Noise or other glitches may cause the keyboard to get out of sync
with the conputer.
This means that the keyboard is finished
transmitting a code, but the computer is somewhere in the middle
of receiving it.
If this happens, the keyboard will not receive its handshake
pulse at the end of its transmission.
If the handshake pulse
does not arrive within 143 ms of the last clock of the
transmission, the keyboard will assume that the computer
is still waiting for the rest of the transmission and is
therefore out of sync.
The keyboard will then attenpt to
restore sync by going into "resync mode."
In this mode, the
keyboard clocks out a 1 and waits for a handshake pulse.
If none arrives within 143 ms, it clocks out another 1 and
waits again.
This process will continue until a handshake
pulse arrives.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents