Keypad Operation; Keypad Matrix Construction; Keypad Port Configuration; Keypad Matrix Scanning - Motorola Freescale Semiconductor M-Core MMC2001 Reference Manual

Table of Contents

Advertisement

KCDx — Keypad Column x Data Bit
KRDx — Keypad Row x Data Bit
This register is not initialized by reset. Valid data should be written to this register
before any bits are configured as outputs.

14.4 Keypad Operation

The keypad port is designed to simplify the software task of scanning a keypad
matrix. With appropriate software support, the KPP is capable of detecting, debounc-
ing, and decoding one or two keys pressed simultaneously in the keypad.
Logic in the KPP can detect a key press even while the processor is in one of the low-
power standby modes. The KPP may generate a CPU interrupt any time a key press
or key release is detected. This interrupt can force the processor out of a low-power
mode.

14.4.1 Keypad Matrix Construction

The keypad port is designed to interface to a keypad matrix which shorts the inter-
secting row and column lines together whenever a key is depressed. The interface is
not optimized for other switch configurations.

14.4.2 Keypad Port Configuration

Software must initialize the keypad port for the size of the keypad matrix. Pins con-
nected to the keypad columns should be configured as open-drain outputs. Pins con-
nected to the keypad rows should be configured as inputs. On-chip pull-up resistors
are implemented for active keypad rows, as defined in SECTION 4 SIGNAL
DESCRIPTIONS.
Row inputs must also be enabled in the keypad control register to be active in the
interrupt generation circuit.
Discrete switches that are not part of the matrix may be connected to any unused row
inputs. The second terminal of the discrete switch is connected to ground. The hard-
ware detects closures of these switches without the need for software polling.

14.4.3 Keypad Matrix Scanning

Keypad scanning is performed by a software loop that walks a zero across each of
the keypad columns, reading the value on the rows at each step. The process is
repeated several times in succession, with the results of each pass optionally com-
pared with those from the previous pass. When three or four consecutive scans yield
the same key closures, a valid key press has been detected. Software can then
decode exactly which switch was depressed and pass the value up to the next higher
software layer.
The basic debouncing period to be defined in the software routine can be controlled
with an internal timer. The basic period is the period between the scan of two consec-
utive columns, so the debounce time between two consecutive scans of the whole
matrix equals the number of columns multiplied by the basic period.
MOTOROLA
14-6
All manuals and user guides at all-guides.com
Freescale Semiconductor, Inc.
KEYPAD PORT
For More Information On This Product,
Go to: www.freescale.com
MMC2001
REFERENCE MANUAL

Advertisement

Table of Contents
loading

Table of Contents