Skip to content

The keypad map

Every key on the KIM keypad is a number underneath. An MM74C922 encoder — sixteen keys natively, extended to twenty-four with a 74HC00 — scans the pad and hands the 65C21 PIA a five-bit code on PA0PA4. The KC Monitor looks that code up and decides what it means.

You need this if you are writing your own code for the keypad. If you are just using the KC Monitor, The KIM keypad is the page you want.

A close-up of the keypad: sixteen white keys numbered 0 to 9 and A to F, with dark Esc, INS, DEL, PGUP, PGDN and arrow keys around them.
Twenty-four keys. The white ones are the hexadecimal digits; the dark ones move you about and change what you are looking at.

The pad as it sits

ESCINSPGUPA
DELPGDNB
789C
456D
123E
0F

Every code

The LCD column is the single character the monitor shows for that key while you are navigating.

CodePA4…PA0KeyOn the LCDHex value
$000 0 0 0 0<
$010 0 0 0 1111
$020 0 0 1 0222
$030 0 0 1 1333
$040 0 1 0 0444
$050 0 1 0 1555
$060 0 1 1 0666
$070 0 1 1 1777
$080 1 0 0 0888
$090 1 0 0 1999
$0A0 1 0 1 0000
$0B0 1 0 1 1>
$0C0 1 1 0 0FF15
$0D0 1 1 0 1EE14
$0E0 1 1 1 0DD13
$0F0 1 1 1 1CC12
$101 0 0 0 0ESC*
$111 0 0 0 1INSI
$121 0 0 1 0PGUPU
$131 0 0 1 1AA10
$141 0 1 0 0^
$151 0 1 0 1DELX
$161 0 1 1 0PGDNN
$171 0 1 1 1BB11

The code is not the value

Nowhere do the two line up. Key 0 is code $0A. C to F run backwards$0C is F and $0F is C. The encoder numbers the switches in the order they sit on the board, and the firmware turns that into a digit with a lookup table.

If you read a code off the port yourself, you must look it up. There is no arithmetic that gets you there.

How a press arrives

The encoder raises its data-available line into the PIA's CA1, which fires an interrupt. The handler reads the code off PA0PA4 and CA2 drops the encoder's output enable again.

So the monitor never sits in a polling loop and never misses a keystroke, even while it is running your program. That is also how ESC can stop something that has no intention of stopping.

The same PIA drives the display: Port A's top three lines are the LCD's RS, R/W and E, and Port B is its data bus. One chip, two jobs.

Written for BIOS v1.5. Released under the MIT License.