Wednesday, 1 April 2020

6502 Project - Hex Keypad


Introduction
As part of my 6502 computer project I have put together a working prototype keypad and interface that allows full interaction with the system monitor I have programmed in the system EEPROM.

The circuit, description and images below will hopefully be of interest and can be used to inform your own project(s).

Background
In my previous article about my 6502 CPU based computer, I indicated that I wanted to experiment with external interfacing projects and components.

My working setup allows me to use serial communications with a Windows based PC, running Realterm, connected to an FT232 USB-Serial interface to the 6551 ACIA chip. This 2-way communications allow full interaction with the EEPROM based monitor to execute List, Save and Goto commands.

To experience the true 'legacy' feel, I wanted to produce a Hexadecimal keypad to allow interaction with the monitor without the need for a serial connected PC.

Design
After some research and a bit of thinking, I came up with the solution below:
Hexadecimal keypad interface circuit
Features

The main features that I particularly like:

a. The 74C922 takes care of the mapping of key switches to 4-bit outputs (Hex).
b. The 74C922 takes care of any switch bounce issues.
c. As each switch is operated, the 74C922 generates a 'strobe' output which can be used for controlling the 74C922 output and to generate (via the 6821) interrupts.
d. The D2815 EEPROM can be programmed to provide any 8-bit output for any 5-bit address selected.
e. The design doesn't have dependencies on the host 6502 computer for any switch or input scanning code.

Operation
A 4x4 keypad connects to the 74C922 keypad encoder chip using the Row and Column connections. The keypad character and command mapping is detailed below.

Pressing one of the 16 keys causes the 74C922 to generate a 4-bit code, 0 to 15 (Hex $0-$f) least significant bit on 'A' to most significant bit on 'D'. The Data Available (DA) o/p goes HIGH when a key is pressed. This o/p is applied to an inverter (74LS04), with the inverter o/p connected to the 74C922 /OE. This enables the 74922 o/ps to the EEPROM addresses. The inverter o/p is also applied to the EEPROM /OE allowing the EEPROM data o/ps to appear on the 6821 PB port.

The D2815 EEPROM is programmed with addresses containing ASCII codes corresponding to the key-pad key value. [see table below].

The inverted Data Available o/p is also applied to the 6821 CB1 input, which is configured to respond to a -ve going pulse.  This generates an /IRQB condition to feed to the 6502 /IRQ input.

The Interrupt Service Routine code I put together, responding to this interrupt, instructs the 6502 computer to read the 6821 data port B and passes the ASCII value into the monitor code. This is just the same as taking the ASCII code from the serial input using the ACIA and serial interface.

There are limitations with just having the 16 switch keypad. To operate the monitor, additional inputs are required to provide the commands 'List', 'Save', Colon and Go (to address). Also, the functions of Backspace, Space, Enter and Esc are required.

Using an additional keypad key (I have a 20-way keypad), this can be used to act as a 'shift-key' function, which when pressed with one of the 'numeric' keys generates a 5-bit code. This 5th bit (normally LOW) selects the A4 EEPROM address, which offers an additional 32 combinations of addresses when combined with A0-A3. These addresses contain ASCII codes for additional monitor functional characters [L, S, COLON, G, BS, ENTER, SPACE, ESC]. Details are in the table below.

The shift-key function o/p is generated by a 555 timer configured as a mono-stable, triggered by a 'shift-key' press. The 555 output is enabled using the 74C922 Data Available o/p connected to 555 pin 4, but only if a numeric key-pad key is pressed. I also included an LED on pin 2 as a visual indicator when the 'shift' key is pressed.

Having selected an EEPROM address, the EEPROM data is applied to the 6821 as described above, and acted upon by the monitor as usual.

I have omitted the connectivity to the 6502 and other computer components (EEPROM, SRAM etc) to keep the circuit less cluttered.

The monitor output using the ACIA serial output can be read either by feeding it direct to the Windows PC running Realterm, or in my case, to an LCD 20x4 display (using a serial to LCD interface).

During testing I also connected LEDs to the 6821 Port A as a visual aid, using the Interrupt Service Routine to write out the value 'read' on Port B to Port A.


Keypad
Key
Shift
Key
74C922 Data outputs
D2815 EEPROM Addresses
HexAdr
HEX
ASCII
Shift
Function
A
B
C
D
A4
A3
A2
A1
A0
0
0
0
0
0
0
0
0
0
0
0
00
30

1
0
1
0
0
0
0
0
0
0
1
01
31

2
0
0
1
0
0
0
0
0
1
0
02
32

3
0
1
1
0
0
0
0
0
1
1
03
33

4
0
0
0
1
0
0
0
1
0
0
04
34

5
0
1
0
1
0
0
0
1
0
1
05
35

6
0
0
1
1
0
0
0
1
1
0
06
36

7
0
1
1
1
0
0
0
1
1
1
07
37

8
0
0
0
0
1
0
1
0
0
0
08
38

9
0
1
0
0
1
0
1
0
0
1
09
39

A
0
0
1
0
1
0
1
0
1
0
0A
41

B
0
1
1
0
1
0
1
0
1
1
0B
42

C
0
0
0
1
1
0
1
1
0
0
0C
43

D
0
1
0
1
1
0
1
1
0
1
0D
44

E
0
0
1
1
1
0
1
1
1
0
0E
45

F
0
1
1
1
1
0
1
1
1
1
0F
46

0
1
0
0
0
0
1
0
0
0
0
10
4C
L
1
1
1
0
0
0
1
0
0
0
1
11
53
S
2
1
0
1
0
0
1
0
0
1
0
12
3A
:
3
1
1
1
0
0
1
0
0
1
1
13
47
G
C
1
0
0
1
1
1
1
1
0
0
1C
08
BS
D
1
1
0
1
1
1
1
1
0
1
1D
0D
C/R
E
1
0
1
1
1
1
1
1
1
0
1E
20
SPACE
F
1
1
1
1
1
1
1
1
1
1
1F
1B
ESC

Keypad mapping to EEPROM Addresses - ASCII Hex codes



Un-shifted
Shifted
0
1
2
3
L
S
:
G
4
5
6
7




8
9
A
B




C
D
E
F
BS
Enter c/r
SPACE
ESC

Keypad 'button' mapping (un-shifted and shifted)



No comments:

Post a Comment