
CHAPTER 13 APPLICATIONS OF KEY INPUT
This chapter introduces an example of a program that inputs signals from a key matrix of 4
×
8 keys. The key
scan be pressed successively, and two or more keys can be pressed simultaneously. In the circuit shown in this
section, the high-order 4 bits of port 3 (P34 through P37) are used as key scan signals, and port 4
Note
is used as
key return signals. As the pull-up resistor of port 4 for key return, the internal pull-up resistor set by software is used
(refer to
Figure 13-1
).
Port 4 of the 78K/0 series has a function to detect the falling edges of the eight port pins in parallel. If port 4 is
used for key return signals, therefore, the standby mode can be released through detection of a falling edge, i.e.,
by key input.
In this example, the
μ
PD78054 subseries is used.
Note
With the
μ
PD78064, 78064Y, 780308, 780308Y, and 78064B subseries, port 11 is used instead of port 4.
Figure 13-1. Key Matrix Circuit
The input keys are stored to RAM on a one key-to-1 bit basis. The RAM bit corresponding to a pressed key is
set and the bit corresponding to a released key is cleared. By testing the RAM data on a 1-bit-by-1-bit basis starting
from the first bit, the key status can be checked. To absorb chattering, the key is assumed to be valid when four
successive key codes coincide with a given code. For example, if a key code is sampled every 5 ms, chattering of
15 ms to 20 ms can be absorbed. If the key input is changed, a key change flag (KEYCHG) is set.
P34
P35
P36
P37
P47
=
PD78054
μ
P46
P45
P44
P43
P42
P41
P40
Pull-up
resistors
connected
373