Analog Devices AN-660 Application Notes

AN-660
APPLICATION NOTE
One Technology Way • P.O. Box 9106 • Norwood, MA 02062-9106 • Tel: 781/329-4700 • Fax: 781/326-8703 • www.analog.com
XY-Matrix Keypad Interface to MicroConverter
By Brian Moss

INTRODUCTION

Using a keypad input in a MicroConverter application is sometimes required for specic operations. It may be used to input data following a request from the Micro ­Converter or simply to trigger the MicroConverter to initiate a particular operation. The MicroConverter can be congured to poll the keypad continuously for an input, or the keypad interface can be congured in an interrupt driven system, depending on the system requirements.

KEYPAD

The keypa d use d for this app lic ation is a 16- way XY- Matrix hexadecimal keypad (www.eaoswitch.com, Mfgr. No. ECO 16250 06, Farnell order code: 467-212). This keypad has eight connections at the rear—four columns (X1–X4) and four rows (Y1–Y4). Figure 1 and Figure 2 show the front and rear of the keypad.

OPERATION

There are two methods of operation: continuous polling, where the MicroConverter spends most or all of its time checking the keypad for a key press; and interrupt driven, where the MicroConverter is free to perform whatever other tasks are required and checks the keypad only when a key is pressed.
®
Figure 1. Keypad (Front)
REV. 0
Figure 2. Keypad (Rear)
AN-660
–3
AN-660
ADuC8xx
Y1
1
4 5 6 E
7
8 9
D
A 0 B C
2
3
F
Y2
Y3
Y4
X1
X2
X3
X4
10k
10k
10k
10k
P2.1
P2.0
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
RxD TxD
RST
KEYPAD
RS-232
V
DD
V
DD
V
DD
REV. 0
Figure 3. Continuous Polling Circuit

Continuous Polling Operations

In this mode of operation, the MicroConverter continu­ously polls the keypad for a key press. This operation is used where the MicroConverter has completed a task and is now waiting for input before proceeding. In this mode, the keypad is connected to one port of the MicroConverter, Port 2 in this example. Figure 3 shows the connectivity. The output from the MicroConverter, following a key press, is viewed using HyperTerminal running on a PC. The MicroConverter is connected to the PC via the COM1 port. This is the reason for showing the RS-232 connection.
As can be seen in Figure 3, the four columns (X1 to X4) are pulled up to VDD and are also connected to four of the MicroConver ter port pins (P2.4 to P2.7). The four
rows (Y1 to Y2) are connected to the other four port pins (P2.0 to P2.3). The MicroConverter outputs 0 or drives low the keypad rows (P2.0 to P2.3) one at a time and checks the columns (P2.4 to P2.7) for a low condition.
For example, the following is the sequence of events up to a switch press detection (Switch 5 in this case). The MicroConverter outputs a low on P2.0 (Y1) and checks for a low on P2.4 to P2.7. In this case, no low is found and so it returns P2.0 (Y1) to high and moves on to P2.1 (Y2). The MicroConverter now drives P2.1 (Y2) low and again checks P2.4 to P2.7 for a low condition. This time it nds that P2.5 (X2) is low, due to Switch 5 being pressed. The MicroConverter now knows that the interconnect of Y2 and X2 has been shor ted, therefore, this is 5. The code to perform this operation is given in the accom ­panying KEYSPOLL.ASM le.
–2–
REV. 0
Loading...
+ 2 hidden pages