Table 14. GPIO Alternate Functions
I/O Select Bit = 1
I/O Select Bit = 1
The keypad interface consists of eight strobe lines and four
return lines. This allows for a keypad matrix of up to 32 keys.
The strobe lines are GPIO type signals and the return lines are
dedicated signals. Unused strobe lines can be used as extra
GPIO signals if required. If a keypad matrix of more than 32
keys is required, one of the GPIO signals (GPIO Port A) can
be configured as a return line to give a total matrix of 40 keys.
The GPIO is configured as a keypad return line by setting the
Port A I/O select bit to “1” (refer to the GPIO section of this
Data Sheet for more information).
Figure 7 illustrates a typical keypad interface circuit. The strobe
lines are output from the BP and connected to the keypad
columns. The return lines are input to the BP and connected to
the keypad rows.
Keypad Scan _______________________________________
Once every frame (4.6 ms) the BP drives one of the strobe lines
low and all of the others high. If a key connected to the strobe
line that is driven low is pressed during this time, the return line
that is also connected to this key will be pulled low. This triggers
an interrupt to the microcontroller to indicate that a key has been
pressed. Since the microcontroller knows which strobe line it is
driving low and which return line has been driven low by the
keypress, it can uniquely identify the key pressed.
A complete scan of the entire keypad requires 4.6 ms multiplied
by the number of strobe lines:
Complete keyboard scan time = 4.6 ms × 8 = 36.8 ms
Key debounce is performed by the software.
Keypad Registers ___________________________________
There are three keypad registers used to configure and monitor
the keypad interface: the Keypad I/O Configuration Register,
Keypad Strobe Register, and the Keypad Return Lines Register.
The address and default values for the keypad registers are
specified in Table 2.
Keypad I/O Configuration Register. The Keypad I/O
Configuration Register is used to set up the strobe lines as
either inputs or outputs. Each of the strobe lines has a related
bit that sets the direction of the pin. If the bit is set to “0,” the pin
is configured as an output. If the bit is set to “1.” the pin is
configured as an input. There is a one-to-one mapping between
the bits and the keypad strobes (i.e., bit  configures keypad
strobe 0, bit configures keypad strobe , etc.).
The default value of this is 0xFF, which configures all the
keypad strobes as outputs from the BP.
June 14, 2000
Proprietary Information and Specifications are Subject to Change