STMPE2401 is the first in the family of STMicroelectronic’s expander logic products. The
principle of a basic expander logic is the provision of additional I/Os that can be used by the
host processor to implement additional features such as expanding the number of control
signals and mixed signal lines or controlling numerous peripherals.
In addition to the above mentioned basic features, STMPE2401 comes with integrated
intelligence to implement advanced features like Keypad scanning and PWM control. This
application note details the setup and programming of the integrated keypad matrix
controller in STMPE2401.
STMPE2401 can be widely used in the fields of Mobile Communications, Portable media
players, Game console, Mobile Phones, Smart Phones, Consumer Electronics and
computer peripherals like state-of-the-art printers, and Advanced embedded systems.
This application note explains the setup and programming of the integrated keypad matrix
controller in STMPE2401. This document also includes a brief description of the timing
constraints and an example of the programming sequence to illustrate the keypad register
configuration for effective functioning of the Keypad controller.
Advantages of a STMPE2401 keypad matrix controllerAN2423
1 Advantages of a STMPE2401 keypad matrix
controller
●Low CPU utilization (no polling)
●Low power consumption
●Wake-up feature from sleep mode to reduce power consumption
●Simple driver software
●Simple connection to CPU for configuration and communication
●Combinational keys to enhance gaming experience
●Application: mobile phone keypads, all-in-one printers, embedded systems, etc.
2 Device setup and configuration
The device operates at 1.8 V VCC. The clock can be generated through a 32 KHz crystal
connected across XTALIN, XTALOUT pins or through an external clock on XTALIN pin. The
clock frequency for normal operation should not exceed 32 KHz. The Reset pin should be
pulled high for the device to come out of reset and operate in the normal operating mode.
The device can be accessed through the I
can be connected to the same I
2
Philip I
C specification Ver2.1. The slave address is selected by the state of two pins
2
C bus. STMPE2401 supports 7-bit addressing as per the
(GPIO15 and GPIO23). The state of the pins is latched into STMPE2401 at power on and
these address settings are retained until the power is switched off. The slave address can
be changed and latched in again using the soft_reset option in the SYSCON register.
2
The I
C Read/Write is done byte by byte. The R/W bit is added as the LSB to the 7-bit slave
address to make up one byte to be sent through the I
2
C interface and up to four STMPE2401 devices
2
C interface from the Master.
Table 1.Valid STMPE2401 slave address
ADDR1
(GPIO23)
0042h (1000010b)84h
0143h (1000011b)86h
1044h (1000100b)88h
1145h (1000101b)8Ah
4/22
ADDR0
(GPIO15)
7-bit slave
addressing
8-bit format to be
used (including R/W
bit in LSB)
AN2423Keypad controller
Figure 1.I2C Read/Write protocol
One Byte
Read
Multiple
Byte Read
One Byte
Write
Multiple
Byte Write
Master
Slave
Once the slave address is configured and responds correctly, the internal registers can be
2
accessed through I
C read and write commands.
At power-up all GPIOs function as inputs and by default the interrupt is configured as an
Active Low Level interrupt. The interrupt pin will remain low irrespective of the Interrupt
settings until the Global Interrupt bit (ICR register) is set to '1'.
3 Keypad controller
STMPE2401 comes with an integrated Keypad controller that can control a maximum of
12x8 key matrix. A key press interrupt is generated when a new set of key data is loaded. In
this way, precious CPU resources can be saved by using interrupt servicing instead of
polling.
The main operations of the keypad controller are regulated by four dedicated-key controllers
that support up to four simultaneous dedicated key presses, a key scan controller, and two
normal key controllers. These devices support a maximum of 12x8 key matrix with detection
of two simultaneous key presses.The scanning of each individual row output and column
input can be enabled or masked to support a key matrix of variable size from 1x1 to 12x8.
The first four column inputs can be configured as dedicated keys. If less than 12 columns or
8 rows are used, the rest of the pins can be used for alternate functions like CLKOUT,
Rotator, or GPIO functions.
The operation of the keypad controller is enabled by the SCAN bit of KPC_ctrl register. The
key detection operation always starts with the "any-key" detection whereby the row outputs
are all driven 'LOW' to allow any key press to be sensed.
5/22
Keypad controllerAN2423
_rd_
Every key activity detected will be de-bounced for a period that can be set through the
KPC_ctrl register before a key press or key release is confirmed and updated into the output
FIFO. The key data, indicating the key coordinates and its status (up or down), is loaded into
the FIFO at the end of a specified number of scanning cycles (set through the
KPC_row_msb register). An interrupt will be generated when a new set of key data is
loaded. The FIFO has a capacity of four sets of key data. Each set of key data consists of
three bytes of information when any of the four dedicated keys is enabled. It is reduced to
two bytes when no dedicated key is enabled. If the FIFO is filled up before its contents are
read, a FIFO overflow interrupt is generated. The FIFO continues to hold its contents but
forbids loading of any new key data until the old data is read.
Figure 2.Block diagram of key pad controller
Clk_32KH z
Int_C lk
column_input[7:0]
DKey0~3
(KPC_CTRL)
Dedicated K ey
Controller 0
i2c _w r_ strob e
KPC_COL
Dedicated K ey
Controller 1
i2c_w r_data[7:0]
KPC_ROW
In pu t S e le cto r
Key Scan
Controller
Dedicated K ey
Controller 2
Dedicated K ey
Controller 3
Controller 0
Normal Key
SCAN & HOTKEY
(K PC _ C TR L )
DB_0~7
(K PC _ C TR L )
Normal Key
Controller 2
kpc_wakeup
row_output[1 1:0]
kp c _ in t
strobe i2c_rd_data[7:0]
i2c
The block diagram shows the various inputs to the Keypad Controller block and outputs from
the Keypad controller. The flowchart in Figure 3 describes the Key scan, key press detection
and output FIFO loading operations in the Keypad controller.
6/22
Output Data FIFO
kpc_of
: Control Register
AN2423Keypad controller
N
N
N
N
N
y
N
N
N
p
N
N
N
Figure 3.Flowchart of key scan controller operation
T ran sitio n to
sleep m ode
A ny key down?
A ny row output
Y
Reset
Set scan
count = 0
SCAN = ‘1’?
Y
Drive row
outputs
Y
to d riv e?
Y
Drive one
row o ut
C o lu m n in pu t
detection
Next row?
ut
Increm ent
scan count
C o lu m n in p u t
detection
Y
recorded in the de-
de-bounce buffer 1
W rite d ata to d e -
de-bounce buffer 3
W rite d ata to de -
Start
A ny key dow n?
Y
Is the key
bo un ce b uffer
alread
?
Is norm al key
em pty?
Y
bo un ce b uffer 1
Is norm al key
em pty?
Y
b oun ce b uffer 3
A ny m ore key
down?
Y
A ny data ready
for w rite?
End
Y
Scan count =
register setting?
Y
A cknow ledge data w rite
& generate interrupt
W rite ready data
to o u tpu t F IF O
7/22
Loading...
+ 15 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.