18-bit enhanced port expander with keypad controller
Features
■ 18 GPIOs configurable as GPI, GPO, keypad
matrix, special key or dedicated key function
■ Operating voltage: 1.65 - 3.6 V
■ Hardware keypad controller (KPC)
(10 x 8 matrix with 4 optional dedicated keys
maximum)
■ Keypad controller capable of detecting
keypress in hibernation mode
■ Interrupt output (open drain) pin
■ Advanced power management system
■ Ultra-low standby mode current
■ Programmable pull-up resistors for all GPIO
pins
■ ESD performance on GPIO pins:
– ± 8 kV human body model
(JESD22 A114-C)
■ ESD performance on V
SCL, SDA pins:
– ± 3 kV human body model
(JESD22 A114-C)
, GND, INTB, R
CC
STB
STMPE1801
Xpander Logic™
Flip-chip CSP 25
(2.03 x 2.03 mm)
Description
The STMPE1801 is a GPIO (general purpose
input/output) port expander capable of interfacing
a main digital ASIC via the two-line bidirectional
2
bus (I
,
C). A separate GPIO expander IC is often
used in mobile multimedia platforms to resolve
the problem of the limited number of GPIOs
typically available on digital engines.
The STMPE1801 offers high flexibility, as each
I/O can be configured as input, output, special
key, keypad matrix or dedicated key function. This
device is designed to include very low quiescent
current, and a wakeup feature for each I/O, to
optimize the power consumption of the device.
Potential applications for the STMPE1801 include
portable media players, game consoles, mobile
and smart phones.
Open drain interrupt output pin. Programmable active low
E1OINTB
A1IRSTB
C1ASDAI
D1ASCLI2C clock. Fail safe
(a pull-up resistor is required) or active high (a pull-down
resistor is required). Fail safe. Pull to V
if not in use.
CC
External reset input. Active low. Fail safe. Reset pulse
width must be more than 500 µs to be valid.
2
C data. Fail safe
B4-NCNo connect
B1-V
E2-GNDGround
2.3 GPIO pin functions
Table 3.GPIO pin function
NamePrimary functionAlternate function
GPIO0GPIOKeypad row 0
GPIO1GPIOKeypad row 1
GPIO2GPIOKeypad row 2
GPIO3GPIOKeypad row 3
GPIO4GPIOKeypad row 4
GPIO5GPIOKeypad row 5
GPIO6GPIOKeypad row 6
GPIO7GPIOKeypad row 7
GPIO8GPIOKeypad column 0
GPIO9GPIOKeypad column 1
CC
Power supply
GPIO10GPIOKeypad column 2
GPIO11GPIOKeypad column 3
GPIO12GPIOKeypad column 4
6/60Doc ID 17884 Rev 3
STMPE1801Pin settings
Table 3.GPIO pin function
NamePrimary functionAlternate function
GPIO13GPIOKeypad column 5
GPIO14GPIOKeypad column 6
GPIO15GPIOKeypad column 7
GPIO16GPIOKeypad column 8
GPIO17GPIOKeypad column 9
The default function is always GPIO. As soon as the key scanning is enabled through the
keypad registers, the function is then switched to the key function and then any configuration
made in the GPIO registers is ignored.
Doc ID 17884 Rev 37/60
Maximum ratingsSTMPE1801
3 Maximum ratings
Stressing the device above the rating listed in the “absolute maximum ratings” table may
cause permanent damage to the device. These are stress ratings only and operation of the
device at these or any other conditions above those indicated in the operating sections of
this specification is not implied. Exposure to absolute maximum rating conditions for
extended periods may affect device reliability.
3.1 Absolute maximum ratings
Table 4.Absolute maximum ratings
SymbolParameterValueUnit
V
CC
Input voltage on GPIO pin4.5V
V
IN
V
ESD
V
ESD
Supply voltage4.5V
Minimum ESD protection on each GPIO
pin (HBM model - JESD22 A114-C)
The features supported by the I2C interface are listed below:
2
●I
C slave device
●Operates at V
●Compliant to Philips I
●Supports standard (up to 100 kbps) and fast (up to 400 kbps) modes
●7-bit device addressing modes
●General call
●Start/Restart/Stop
6.1 I2C related pins
●SCL
●SDA
The device supports both 1.8 V I
Vpullup at SCL and SDA externally is greater or equal to V
(1.8 - 3.6 V)
CC
2
C specification version 2.1
2
C and 3.3 V I2C operations. It is recommended that
.
CC
6.2 I2C addressing
The STMPE1801 7-bit addressing is set to 40h.
6.3 Start condition
A Start condition is identified by a falling edge of SDA while SCL is stable at high state. A
Start condition must precede any data/command transfer. The device continuously monitors
for a Start condition and does not respond to any transaction unless one is encountered.
The first byte is scanned after the START command is detected to check for device ID.
Ensure that all state machines are flushed when START instruction is issued.
6.4 Stop condition
A Stop condition is identified by a rising edge of SDA while SCL is stable at high state. A
Stop condition terminates the communication between the slave device and bus master. A
read command that is followed by NoAck can be followed by a Stop condition to force the
slave device into idle mode. When the slave device is in idle mode, it is ready to receive the
2
next I
C transaction. A Stop condition at the end of a write command stops the write
operation to the registers.
Once the Stop condition is detected, the device should release the bus and go to Hibernate
mode if there is no more activity.
2
An I
C transaction with a START bit followed immediately by a STOP condition should not
cause any I
2
C lock-up.
14/60Doc ID 17884 Rev 3
STMPE1801I2C specification
6.5 Acknowledge bit (ACK)
The acknowledge bit is used to indicate a successful byte transfer. The bus transmitter
releases the SDA after sending eight bits of data. During the ninth bit, the receiver pulls the
SDA low to acknowledge the receipt of the eight bits of data. The receiver may leave the
SDA in high state if it does not acknowledge the receipt of the data.
6.6 Data input
The device samples the data input on SDA on the rising edge of the SCL. The SDA signal
must be stable during the rising edge of SCL and the SDA signal must change only when
SCL is driven low.
6.7 Memory addressing
For the bus master to communicate to the slave device, the bus master must initiate a Start
condition and be followed by the slave device address. Accompanying the slave device
address, there is a Read/Write bit (R/W
operation.
If a match occurs on the slave device address, the corresponding device gives an
acknowledgement on the SDA during the 9th bit time. If there is no match, it deselects itself
from the bus by not responding to the transaction.
). The bit is set to 1 for Read and 0 for Write
6.8 Operation modes
Table 9.Operating modes
ModeByteProgramming sequence
Read≥1
START, Device address, R/W
=0, Register Address to be read
RESTART, Device Address, R/W
=1, Data Read, STOP
If no STOP is issued, the Data Read can be continuously performed. If
the register address falls within the range that allows address autoincrement, then register address auto-increments internally after every
byte of data being read. For register address that fails within a nonincremental address range, the address is kept static throughout the
entire read operation. Refer to Table 8.: STMPE1801 register summary
table for the address ranges that are auto-increment and non-increment.
An example of such a non-increment address is FIFO.
Doc ID 17884 Rev 315/60
I2C specificationSTMPE1801
M
Table 9.Operating modes
ModeByteProgramming sequence
START, Device Address, R/W
=0, Register Address to be written, Data Write, STOP
If no STOP is issued, the Data Write can be continuously performed. If
the register address falls within the range that allows address autoincrement, then register address auto-increment internally after every
Write≥1
byte of data being written. For those register addresses that fall within a
non-incremental address range, the address will be kept static
throughout the entire write operation. Refer to Table 8.: STMPE1801
register summary table for the address ranges that are auto-increment
and non-increment. An example of a non-increment address is Data
Port for initializing the PWM.
Figure 3.Operating modes
One B yte
Read
More than
One B yte
Read
One B yte
Write
ore than
One B yte
Write
Start
Start
Start
Start
Dev
Addr
Dev
Addr
Dev
Addr
Dev
Addr
Master
Slave
Reg
Addr
RnW=0
Ack
Reg
Addr
RnW=0
Ack
Reg
Addr
RnW=0
Ack
Reg
Addr
RnW=0
Ack
Ack
Ack
Ack
Ack
Dev
Addr
reStart
Dev
Addr
reStart
Data to
be
Written
Data to
Write
RnW=1
RnW=1
Ack
Stop
Data to
Write + 1
Ack
Dat a
Rea d
Ack
Ack
Dat a
Rea d
Data to
Write + 2
Ack
NoAck
Stop
Rea d + 1
Ack
Dat a
Ack
Stop
Rea d + 2
Ack
Dat a
NoAck
Stop
16/60Doc ID 17884 Rev 3
STMPE1801I2C specification
6.9 General call address
A general call address is a transaction with the slave address of 0x00 and R/W =0. When a
general call address is asserted, the STMPE1801 responds to this transaction with an
acknowledgement and behaves as a slave-receiver mode. The meaning of a general call
address is defined in the second byte sent by the master-transmitter.
Table 10.General call address
R/W
Second byte
value
00x06
00x00Not allowed as second byte.
A 2-byte transaction in which the second byte tells the slave device to reset
and write (or latch in) the 2-bit programmable part of the slave address.
Note:All other second byte values are ignored.
Definition
Doc ID 17884 Rev 317/60
System controllerSTMPE1801
7 System controller
7.1 System level registers
The system controller is the heart of the STMPE1801. It contains the registers for power
control and chip identification.
The system registers are:
AddressRegister name
00CHIP_ID
01VERSION_ID
02SYS_CTRL
CHIP_IDChip identification register
76543 210
8-bit CHIP_ID
RRRRR RRR
11000 001
VERSION_IDVersion identification register
76543 210
8-bit VERSION_ID
RRRRR RRR
00010 000
18/60Doc ID 17884 Rev 3
STMPE1801System controller
SYS_CTRLSystem control register
76543 210
SF_RSTRESERVEDGPI_DB1GPI_DB0RSVD
WRRRR RW RW R
00000 110
Address:02
Type:R/W
Reset:0x06
Description:System control register.
[7] SF_RST: Soft Reset
Writing a ‘1’ to this bit will do a soft reset of the device. Once the reset is done, this bit is
cleared to ‘0’ by the HW.
●Operational mode: This is the mode, whereby normal operation of the device takes
place. In this mode, the main finite state machine (FSM) unit routes 32 kHz clock to all
the device blocks.
●Hibernate mode: This mode is entered automatically in auto-hibernate mode. When the
device is in Hibernate mode, the 32 kHz clock is disabled. If there is a keypad activity,
interrupt event, hotkey activity or I
2
C transaction, the device switches to operational
mode. A reset event brings back the system to operational mode.
7.2.1 Auto-hibernate
The STMPE1801 is set to go into Hibernate mode automatically if there is a period of
inactivity (~ 100
STMPE1801 will continue counting down for hibernation mode activation even if there is an
2
I
C transaction sent by the host to other slave devices. Any I2C transaction from the host to
the STMPE1801 resets the hibernate counter.
Auto-hibernate mode occurs only when all the keys are released and FIFO is emptied
through reading. This is to prevent any loss of data.
The hibernate mode counter should start when any of the following conditions is detected:
–Once the I
–If the device ID in the I
When there is a keypad activity, the device should go into Hibernate mode ONLY when all
the previously pressed keys are released.
20/60Doc ID 17884 Rev 3
µs) following the completion of I
2
C transaction is completed or a STOP condition is detected.
2
C transaction is invalid.
2
C transaction with the host. The
STMPE1801System controller
Any keypad activity, interrupt event, hotkey activity or VALID I2C transaction wakes up the
device from Hibernate mode and switches to operational mode automatically.
7.2.2 Keypress detect in the Hibernate mode
When in Hibernate mode, any keypress detected causes the system to go into operational
mode (~48
detected is valid, the system stays in operation mode. If the key detected is invalid, the
system goes back into Hibernate mode.
µs). The system will then de-bounce the key to detect a valid key. If the keypress
Doc ID 17884 Rev 321/60
Clocking systemSTMPE1801
8 Clocking system
In order to reduce the power consumption, the STMPE1801 turns off the oscillator during
Hibernate mode.
Figure 5.Clocking system
K(Z
/3#
#LOCKCONTROL
3YSTEMCLOCK
8.0.1 Clock source
By default, when the STMPE1801 powers up, it derives a 32 kHz clock from the internal RC
oscillator for its operation.
There are 4 sources of reset:
●RSTB pin
●Low voltage detect (LVD) reset
●Soft reset bit of the SYS_CTRL register
2
●I
C reset from the I2C block.
3#,PIN
!-6
22/60Doc ID 17884 Rev 3
STMPE1801Clocking system
8.0.2 Power mode programming sequence
The device enters auto Hibernate mode when there is inactivity for a fixed period of time.
To wake up the device, the host is required to:
–Send an I
To do a soft reset to the device, the host needs to do the following:
–Write a '1' to bit 7 of the SYS_CTRL register. This bit is automatically cleared upon
reset.
To come out of the Hibernate mode, the following needs to be done by the host:
–Assert a system reset
–Or put a wakeup on the I
–Interrupt activity
2
C transaction to the device.
2
C transaction
Doc ID 17884 Rev 323/60
Interrupt systemSTMPE1801
9 Interrupt system
The STMPE1801 uses a highly flexible interrupt system. It allows the host system to
configure the type of system events that should result in an interrupt, and pinpoints the
source of interrupt by status registers. The INT pin can be configured as active high (a pulldown resistor is required), or active low (a pull-up resistor is required). If INT pin is not in
use, it is necessary to pull INT pin to V
Once asserted, the INT pin would de-assert when a read is done to the corresponding bit
either in the INT_STA register or INT_STA_GPIO register.
When the generation of interrupts by the GPIO as input is enabled for the hot keys, the
latency (time taken from actual transition at GPIO to time of INT pin assertion) is shown in
the following table:
Table 12.GPIO hot keys interrupt latency
State of operationInterrupt latencyComments
Hibernation>200 µs (default)
Active>200 µs (default)
Latency can be programmed by
the GPI_DB bits of SYS_CTRL
register
Doc ID 17884 Rev 325/60
Interrupt systemSTMPE1801
INT_CTRLInterrupt control register
1514131211109876543 2 1 0
INT_CTRL_HIGHINT_CTRL_LOW
ReservedIC2IC1IC0
RRRRRRRRRRRRRRW RWRW
Address:04, 05
Type:R, R/W
Reset:0x00
Description:The interrupt control register is used to configure the interrupt controller. It has global
enable interrupt mask bit that controls the interruption to the host.
[15:3] RESERVED
[2] IC2: Output Interrupt polarity
‘0’ = Active low/falling edge
‘1’ = Active high/rising edge
When this bit is written a ‘1’, it allows interruption to the host. If it is written with a ‘0’, then, it
disables all interruption to the host. Writing to this bit does not affect the INT_EN_MASK value.
26/60Doc ID 17884 Rev 3
STMPE1801Interrupt system
INT_EN_MASKInterrupt enable mask register
1514131211109876543 2 1 0
INT_EN_MASK_HIGHINT_EN_MASK_LOW
RESERVEDIE4IE3IE2IE1IE0
RRRRRRRRRRRRWRWRWRWRW
0000000000000 0 0 0
Address:06, 07
Type:R, R/W
Reset:0x00
Description:The interrupt enable mask register is used to enable the interruption from a particular
interrupt source to the host.
[15:4] RESERVED
[4:0] IE[x]:
Interrupt Enable Mask (where x = 3 to 0)
IE0: Default value is 0.
IE1: Keypad controller interrupt mask
IE2: Keypad controller FIFO overflow interrupt mask
IE3: GPIO controller interrupt mask
IE4: Combination key interrupt enable
Writing a ‘1’ to the IE[x] bit enables the interruption to the host.
Doc ID 17884 Rev 327/60
Interrupt systemSTMPE1801
INT_STAInterrupt status register
1514131211109876543210
INT_STA_HIGHINT_STA _LOW
RESERVEDIS4IS3IS2IS1IS0
RRRRRR RRRRRRRRRR
000000 0000000001
Address:08, 09
Type:R
Reset:0x00
Description:The interrupt status register monitors the status of the interruption from a particular
interrupt source to the host. The INT_STA bits are constantly updated regardless
whether the INT_EN bits are enabled or not.
[15:4] RESERVED
[4:0] IS[x]
Interrupt status (where x = 3 to 0)
Read:
IS0: Wake-up interrupt status
IS1: Keypad controller interrupt status
IS2: Keypad controller FIFO overflow interrupt status
IS3: GPIO controller interrupt status
IS4: Combination key interrupt status
Reading the INT_STA register clears all interrupt status bits to ‘0’ which had been set to ‘1’
prior to the read event.
Description:The interrupt enable GPIO mask register is used to enable the interruption from a
particular GPIO interrupt source to the host. The IEG[17:0] bits are the interrupt
enable mask bits correspond to the GPIO[17:0] pins.
[17:0 IEG[x]: Interrupt enable GPIO mask (where x = 17 to 0)
Writing a ‘1’ to the IEG[x] bit enables the interruption to the host.
Doc ID 17884 Rev 329/60
Interrupt systemSTMPE1801
NT_STA_GPIOInterrupt status GPIO register
76543 210
INT_STA_GPIO_LOW
ISG7ISG6ISG5ISG4ISG3ISG2ISG1ISG0
RRRRR RRR
00000 000
15141312111098
INT_STA_GPIO_MID
ISG15ISG14ISG13ISG12ISG11ISG10ISG9ISG8
RRRRR RRR
00000 000
2322212019181716
INT_STA_GPIO_HIGH
ReservedISG17ISG16
RRRRR RRR
00000 000
Address:0D, 0E, 0F
Type:R
Reset:0x00
Description:The interrupt status GPIO register monitors the status of the interruption from a
particular GPIO pin interrupt source to the host. The INT_STA_GPIO bits are
constantly updated regardless whether the INT_EN_GPIO_MASK bits are enabled or
not. The ISG[17:0] bits are the interrupt status bits correspond to the GPIO[17:0] pins.
[17:0 ISG[x]
Interrupt status GPIO (where x = 17 to 0)
ISG[x] will be set to ‘1’ if an interrupt is detected on the corresponding GPIO pin.
Reading the INT_STA_GPIO register clears all interrupt status GPIO bits to ‘0’ which had been
set to ‘1’ prior to the read event.
30/60Doc ID 17884 Rev 3
STMPE1801Interrupt system
9.3 Programming sequence
To configure and initialize the interrupt controller to allow interruption to host, observe the
following steps:
1.Set the INT_EN_MASK and INT_EN_GPIO_MASK registers to the desired values to
enable the interrupt sources that are to be expected to receive from.
2. Configure the output interrupt type and polarity and enable the global interrupt mask by
writing to the INT_CTRL.
3. Wait for interrupt.
4. Upon receiving an interrupt, the corresponding INT bit is asserted.
5. The host comes to read the INT_STA register through the I
INT_STA bits indicates that the corresponding interrupt source is triggered.
6. If the IS3 bit in INT_STA register is set, the interrupt is coming from the GPIO controller.
Then, a subsequent read is performed on the INT_STA_GPIO register to obtain the
interrupt status of all 18 GPIOs to locate the GPIO that triggers the interrupt. This is a
‘Hot Key’ feature.
7. After obtaining the interrupt source that triggers the interrupt, the host performs the
necessary processing and operations related to the interrupt source.
8. All IS[x] bits in INT_STA register and ISG[x] bits in INT_STA_GPIO register which are
set to ‘1’ prior to the read event are cleared to ‘0’ automatically once the reading of the
registers are completed.
9. Any interrupt inputs received between reading and auto clearing of the registers are
kept in a shadow register and updated into the INT_STA and INT_STA_GPIO registers
once the auto clearing is completed.
10. Once the interrupt is cleared, the INT pin is also de-asserted if the interrupt type is level
interrupt. An edge interrupt only asserts a pulse width of 200 µs.
11. When the interrupt function is no longer required, the IC0 bit in INT_CTRL may be set
to ‘0’ to disable the global interrupt mask bit.
2
C interface. A ‘1’ in the
Doc ID 17884 Rev 331/60
GPIO controllerSTMPE1801
10 GPIO controller
A total of 18 GPIOs are available in the STMPE1801 port expander device. Most of the
GPIOs are sharing physical pins with alternate functions. The GPIO controller contains the
registers that allow the host system to configure each of the pins into either a GPIO, or one
of the alternate functions. Unused GPIOs should be configured as outputs to minimize the
power consumption.
Table 13.GPIO controller registers
Auto-increment
AddressRegister nameDescription
(during sequential
R/W)
10GPIO_SET_LOW
11GPIO_SET_MIDYes
12GPIO_SET_HIGHYes
13GPIO_CLR_LOW
14GPIO_CLR_MIDYes
15GPIO_CLR_HIGHYes
16GPIO_MP_LOW
17GPIO_MP_MIDYes
18GPIO_MP_HIGHYes
19GPIO_SET_DIR_LOW
1AGPIO_SET_DIR_MIDYes
1BGPIO_SET_DIR_HIGHYes
1CGPIO_RE_LOW
1DGPIO_RE_MIDYes
1EGPIO_RE_HIGHYes
1FGPIO_FE_LOW
20GPIO_FE_MIDYes
21GPIO_FE_HIGHYes
22GPIO_PULL_UP_LOW
GPIO set pin state register
GPIO clear pin state register
GPIO monitor pin state register
GPIO set pin direction register
GPIO rising edge register
GPIO falling edge register
Ye s
Ye s
Ye s
Ye s
Ye s
Ye s
Ye s
23GPIO_PULL_UP_MIDYes
24GPIO_PULL_UP_HIGHYes
32/60Doc ID 17884 Rev 3
GPIO pull up register
STMPE1801GPIO controller
10.1 GPIO control registers
A group of registers is used to control the exact function of each of the 18 GPIOs.
All the GPIO registers are named as GPIO_xxx_yyy, where:
–xxx represents the functional group
–yyy represents the byte position of the GPIO (LOW/MID/HIGH)
The function of each bit is shown in the following table:
Register nameDescriptionFunction
GPIO_MP_yyyGPIO monitor pin state
GPIO_SET_yyyGPIO set pin state
GPIO_CLR_yyyGPIO clear pin state
GPIO_SET_DIR_yyyGPIO set pin direction
GPIO_RE_yyyGPIO rising edge
GPIO_FE_yyyGPIO falling edge
GPIO_PULL_UP_yyyGPIO pull upSet to ‘1’ enable internal pull-up resistor.
Reading this bit yields the current state of the bit. Writing
has no effect.
Writing ‘1’ to this bit causes the corresponding GPIO to go
to ‘1’ state. Writing ‘0’ has no effect.
Writing ‘1’ to this bit causes the corresponding GPIO to go
to ‘0’ state. Writing ‘0’ has no effect.
‘0’ sets the corresponding GPIO to input state, and ‘1’ sets
it to output state.
Set to ‘1’ enable rising edge detection on the
corresponding GPIO.
Set to ‘1’ enable falling edge detection on the
corresponding GPIO.
Doc ID 17884 Rev 333/60
GPIO controllerSTMPE1801
10.2 Hotkey feature
A GPIO is known as ‘Hotkey’ when it is configured to trigger an interruption to the host
whenever the GPIO input is being asserted. This feature is applicable in operational mode
as well as in Hibernate mode.
10.2.1 Programming sequence for Hotkey
1.Configure the GPIO pin into input direction by setting the corresponding bit in the GPIO
set pin direction registers [GPIO_SET_DIR_yyy].
2. Set the GPIO rising edge registers [GPIO_RE_yyy] and GPIO falling edge registers
[GPIO_FE_yyy] to the desired values to enable the rising edge or falling edge
detection.
3. Configure and enable the interrupt controller to allow the interruption to the host.
4. Now, the GPIO expander may enter Hibernate mode if there is no activity.
5. Upon any hot-key being asserted, the device will wake up and issue an interrupt to the
host.
Below are the conditions to be fulfilled in order to configure a Hot Key:
1.The pin is configured into GPIO mode and as input pin.
2. The global interrupt mask bit is enabled.
3. The corresponding GPIO interrupt mask bit is enabled.
10.2.2 Minimum pulse width
The minimum pulse width of the assertion of the Hotkey is dependent on the de-bounce
time configured. It must be greater than the de-bounce value configured. Any pulse width
less than the stated value may not be registered.
34/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
11 Keypad controller
The keypad controller consists of:
–4 dedicated key controllers that support up to 4 simultaneous dedicated key
presses;
–a keyscan controller support a maximum of 10 x 8 key matrix with detection of
three simultaneous key presses;
–8 special function key controllers that support up to 8 simultaneous “special
function” key presses.
The key detection priority is dedicated, special function and normal keys.
Four of the row inputs can be configured as dedicated keys through the setting of Dkey0~3
bits of the KPC_CTRL register. The normal key matrix size can be configured through the
setting of KPC_ROW and KPC_COL registers. The scanning of each individual row input
and column output can be enabled or masked to support a key matrix of variable size from 1
x 1 to 10 x 8. It is allowed to have other 8 special function keys incorporated in the key
matrix.
The operation of the keypad controller is enabled by the SCAN bit of KPC_CTRL register.
Every key activity detected is de-bounced for a period set by the DB_1~7 bits of 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 by SCAN_COUNT0~3 bits of
KPC_CTRL_MID register). An interrupt is generated when a new set of key data is loaded.
The FIFO has a capacity for ten sets of key data. Each set of key data consists of 5 bytes of
information when any of the four dedicated keys is enabled. It is reduced to 4 bytes when no
dedicated key is involved. When the FIFO is full before its content is read, an overflow signal
is generated while the FIFO will continue to hold its content but forbid loading of new key
data set.
Doc ID 17884 Rev 335/60
Keypad controllerSTMPE1801
Figure 7.Keypad controller
/UTPUT
COLUMN
-ATRIXKEYPAD
)NPUTROW
!-6
The keypad rows enabled by the KPC_ROW register are normally 'high', with the
corresponding input pins pulled up by resistors internally. After reset, all the keypad columns
enabled by the KPC_COL register are driven 'low' via weak-pull down resistors. The pulldown resistors on the column are weaker than the pull-up resistors on the rows. If a key is
pressed, the stronger pull-up drive on the corresponding row overwrites the weaker pulldown drive on the selected column thus allowing the keyscan controller to sense a "high"
input on the selected column.
Once the keyscan controller senses a "high" on the selected column, the output buffer for
the selected column drives the line low overwriting the pull-up resistor on the corresponding
row. The row that senses the "low" signal enables the key scan controller to decode the key
coordinates (its corresponding row number and column number), save the key data into a
de-bounce buffer if available, confirm if it is a valid key press after de-bouncing, and update
the key data into output data FIFO if valid.
The key press/release detection mechanism is listed below:
1.When the GPIO is configured as keypad, the ROWS have internal "strong" pull-up and
COLUMNS have internal "weak" pull-down. The initial states of the ROWS are Logic
High and the COLUMNS are Logic Low.
2. When a keypad is pressed, the corresponding Row and Column form a Resistor
Voltage Divider Network. Since the pull-up resistance of the ROW is stronger than the
pull-down resistance of the COLUMN, the COLUMN is pulled to Logic High.
3. Once the COLUMN's state changes to Logic High, the state machine initiates a keyscan cycle and drives the selected COLUMN to Logic Low. A low is detected on the
36/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
key-press ROW. This is because the row and column node of key press are shorted
together.
4. The state machine continues to poll while the key is still pressed and is reinitialized
once all the keys are released.
The key detection sequence is described below:
1.The column outputs are initially not driven.
2. Then the row inputs are checked for any special function keys.
3. Next, the columns are checked for any normal key presses.
4. With the internal pull-down resistor on the columns, the column senses a logic low. But
when there is a normal key press, the pull up on the row and pull down on the column
forms a resistor voltage divider. Since the pull up resistor is sized much smaller than
the pull down resistor, the voltage on the column is pulled to logic high state.
5. Then only the configured columns that sensed a high are driven low in turn and check
for normal key presses.
This eliminates the need to drive columns that do not have any key press. This in turn
reduces the switching amount and hence the reduction in noise and EMI.
Also the 4 mA IO during GPIO mode is 1 mA in keypad mode.
Doc ID 17884 Rev 337/60
Keypad controllerSTMPE1801
11.1 Keypad configurations
The keypad controller supports the following types of keys:
●Up to 10 columns * 8 rows matrix keys
●Up to 8 special function keys
●Up to 4 dedicated keys
Figure 8.Keypad configuration
Matrix keypad (10*8)
Input Row 0-7
10*8 (80) Matrix Keys
8 Special Function Keys
0 Dedicated Keys
STMPE1801
Output Column 0
-9
Special Function Keys
38/60Doc ID 17884 Rev 3
!-6
STMPE1801Keypad controller
Figure 9.Keypad configurations
Matrix keypad (10*4)
STMPE1801
Output Column 0-9
Input Row 0-7
Dedicated Keys
Special Function Keys
10*4 (40) Matrix Keys
4 Special Function Keys
4 Dedicated Keys
!-6
Doc ID 17884 Rev 339/60
Keypad controllerSTMPE1801
11.2 Keypad controller registers
The mapping between the keypad controller (rows and columns) and the GPIO is based on
Section 2.3.
Table 14.Keypad controller registers
AddressRegister nameDescription
30KPC_ROWKeypad row registerYes
31KPC_COL_LOW
32KPC_COL_HIGHYes
33KPC_CTRL_LOW
34KPC_CTRL_MIDYes
35KPC_CTRL_HIGHYes
36KPC_CMDKey command registerYes
37KPC_COMBI_KEY_0Keypad combination key mask 0Yes
38KPC_COMBI_KEY_1Keypad combination key mask 1Yes
39KPC_COMBI_KEY_2Keypad combination key mask 2Yes
3AKPC_DATA_BYTE0
3BKPC_DATA_BYTE1Yes
3CKPC_DATA_BYTE2Yes
3DKPC_DATA_BYTE3Yes
3EKPC_DATA_BYTE4Yes
Keypad column register
Keypad control register
Keypad data register
Auto-increment
(during sequential R/W)
Ye s
Ye s
Ye s
40/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
KPC_ROWKeypad controller row register
76543 210
Input Row 0 - 7
RWRWRWRWRWRWRWRW
00000 000
Address:30
Type:R/W
Reset:0x00
Description:Keypad row scanning
[7:0] Input row 0 – 7:
‘1’: Turn on scanning of the corresponding row
.‘0’: Turn off
KPC_COL_HIGHKeypad controller column (HIGH)
15141312111098
RESERVEDOutput Column 8 - 9
RRRRRRRWRW
00000 000
Address:32
Type:R/W
Reset:0x00
Description:Keypad column scanning register.
[15:10] RESERVED
[9:8] OUTPUT COLUMN 8-9:
‘1’: Turn on scanning of the corresponding column.
‘0’: Turn off
Doc ID 17884 Rev 341/60
Keypad controllerSTMPE1801
KPC_COL_LOWKeypad controller column (LOW)
76543 210
Output Column 0 - 7
RWRWRWRWRWRWRWRW
00000 000
Address:31
Type:R/W
Reset:0x00
Description:Keypad column scanning register.
[7:0] OUTPUT COLUMN 0-7:
‘1’: Turn on scanning of the corresponding column.
‘0’: Turn off
KPC_CTRL_LOWKeypad controller control (Low)
76543 210
SCAN_COUNT 0 – 3DKEY 0 – 3
RWRWRWRWRWRWRWRW
00000 000
Address:33
Type:R/W
Reset:0x00
Description:Keypad control register.
[7:4] SCAN_COUNT_0-3:
Number of key scanning cycles elapsed before a confirmed key data is updated into output
data FIFO (0-15 cycles)
[3] DKEY_3: Set ‘1’ to use input row 3 as dedicated key
[2] DKEY_2: Set ‘1’ to use input row 2 as dedicated key
[1] DKEY_1: Set ‘1’ to use input row 1 as dedicated key
[0] DKEY_0: Set ‘1’ to use input row 0 as dedicated key
42/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
KPC_CTRL_MIDKeypad controller control (Mid)
76543 210
DB[7:2]DB0RSVD
RWRWRWRWRWRWRRW
01100 010
Address:34
Type:R/W
Reset:0x31
Description:Keypad control register.
[7:1] DB[7:2] and DB0:
DB0 bit is fixed to ‘1’.
10-127ms of de-bounce time
De-bounce time range is from 10 ms to 127 ms with 50 ms as the default.
[0] RESERVED
Doc ID 17884 Rev 343/60
Keypad controllerSTMPE1801
KPC_CTRL_HIGHKeypad controller control (High)
76543 210
RSVDCMB_KEYRESERVEDSCAN_FREQ
RRWRRR RRW
01000 000
Address:35
Type:R/W, R
Reset:0x40
Description:Keypad data register.
[7:4] RESERVED
[6] CMB_KEY:
Combination key mode
1: AND function for combination-key interrupt (default).
0: OR function for combination-key interrupt.
[5:2] RESERVED
[1:0] SCAN_FREQ:
Scan frequency based on internal 32KHz clock
00: 60 Hz (default)
01: 30 Hz
10: 15 Hz
11: 275 Hz
KPC_CMDKeypad command register
76543 210
RSVDRSVDRSVDRSVDRSVDRSVDKPC_LOCKSCAN
RRRRRRRWRW
00000 00
Address:36
Type:R/W, R
Reset:0x00
Description:Keypad command register.
[7:2] RESERVED
[1] KPC_LOCK:
Keypad lock control bit
1: Writing 1 to enter key pad lock state when the key press stops.
44/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
The KPC_LOCK bit is only used when a combination key is configured in the device. If there
is no combination key programmed, then this bit is not used. This command is used in
conjunction with the combination keys. After the device has entered the keypad lock state,
all subsequent key presses are ignored until the combinational key(s) are detected.
Thereafter, the device exits the lock state, sets the combinational key wakeup status in the
interrupt status register bit IS[4] and sends out the interrupt if it was enabled.
0: Writing 0 aborts the key lock
Writing a 0 to this bit cancels any earlier key lock execution command. If the device has
already entered the lock state, writing 0 exits the lock state.
This bit is readable by the Host and the read status is described as follows:
Reading [1]: KPC lock execution is not completed. It is either waiting for the key press to
stop to enter the lock state or it is already in the lock state.
Reading [0]: KPC is already not in lock state, and not waiting to enter lock state.
[0]SCAN:
1: to start scanning
0: to stop
Note:All the key configurations and control must be completed before executing the scan
command. Any configuration and control change while scan is active is not supported.
Doc ID 17884 Rev 345/60
Keypad controllerSTMPE1801
11.3 Data registers
The KPC_DATA register contains five bytes of information. The first three bytes store the key
coordinates and status of any three keys from the normal key matrix, while the fourth byte
stores the status of special function keys and the fifth byte consists of the status of
dedicated keys.
Note:When accessing the KPC DATA FIFO, it is mandatory to read all five bytes of KPC_Data
registers together consecutively.
46/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
KPC_DATA_BYTE0Keypad data byte 0
76543 210
UP/DWNC3C2C1C0R2R1R0
RRRRR RRR
11111 000
Address:3A
Type:R
Reset:0xF8
Description:Keypad data register.
[7] UP/DWN:
0: key-down
1: key-up
[6:3] C[3:0]:
Column number of key 1 (valid range: 0000-1001)
0x1111: No key
[2:0] R[2:0]:
Row number of key 1 (valid range: 000-111)
KPC_DATA_BYTE1Keypad data byte 1
76543 210
UP/DOWNC3C2C1C0R2R1R0
RRRRR RRR
11111 000
Address:3B
Type:R
Reset:0xF8
Description:Keypad data register.
[7] UP/DOWN:
0: key-down
1: key-up
[6:3] C[3:0]:
Column number of key 2 (valid range: 0000-1001)
0x1111: No key
[2:0] Row number of key 2 (valid range: 000-111)
Doc ID 17884 Rev 347/60
Keypad controllerSTMPE1801
KPC_DATA_BYTE2Keypad data byte 2
76543 210
UP/DOWNC3C2C1C0R2R1R0
RRRRR RRR
11111 000
Address:3C
Type:R
Reset:0xF8
Description:Keypad data register.
[7] UP/DOWN:
0: key-down
1: key-up
[6:3] C[3:0]: Column number of key 3 (valid range: 0000-1001)
0x1111: No key
[2:0] R[2:0]: Row number of key 3 (valid range: 000-111)
KPC_DATA_BYTE3Keypad data byte 3
76543 210
SF7SF6SF5SF4SF3SF2SF1SF0
RRRRR RRR
11111 111
Address:3D
Type:R
Reset:0xFF
Description:Keypad data register.
[7:0] SF[7:0]:
0: key-down
1: key-up
48/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
KPC_DATA_BYTE4Keypad data byte 4
76543 210
RESERVEDDedicated Key 0 – 3
RRRRR RRR
00001 111
Address:3E
Type:R
Reset:0x0F
Description:Keypad data register.
[7:4] RESERVED
[3:0] Dedicated key [3:0]:
0: Key down
1: Key up
Doc ID 17884 Rev 349/60
Keypad controllerSTMPE1801
11.4 Keypad combination key registers
The 3 keypad controller mask registers contains the key combination to be used to wake up
the KPC and send an interrupt to the host system.
[7:3] C[4:0]: Column number of key n (valid range: 00000 – 01001)
[2:0] R[2:0]: Row number of key n (valid range: 000 – 111)
Valid key press value must be entered. The valid range for STMPE1801 is 00 to 4F. Any
other value outside this range is not accepted and a none value of F8 is returned.
50/60Doc ID 17884 Rev 3
STMPE1801Keypad controller
11.5 Using the keypad controller
It is not necessary to explicitly enable the internal pull-up, pull-down and direction by
configuring the GPIO control registers. Once a GPIO is enabled for the keypad function, its
internal pull-up, pull-down and direction is controlled automatically.
The scanning of row inputs should then be enabled for those GPIO ports that are configured
as keypad inputs by writing '1's to the corresponding bits in the KPC_ROW register. If any of
the first four row inputs is to be used as dedicated key input, the corresponding bits in the
KPC_CTRL_MID register should be set to '1'. The bits in the KPC_COL_HIGH and
KPC_COL_LOW registers should also be set correctly to enable the column output
scanning for the corresponding GPIO ports programmed as keypad outputs.
The scan count and de-bounce count should also be programmed into the keypad control
registers before enabling the keypad controller operation. To enable the keypad controller
operation, the SCAN bit in the KPC_CTRL_LOW register must be set to '1'. The keypad
controller operation can be disabled by setting the SCAN bit back to '0'. The KPC interrupt
can be cleared upon status bit read, even if there is unread key-press in the KPC Data
register. It is the host responsibility to read the KPC Data register to access all key-press
data.
11.5.1 Ghost key handling
The ghost key is inherent in keypad matrix that is not equipped with a diode at each of the
keys. While it is not possible to avoid ghost key occurrence, the STMPE1801 allows the
detection of possible ghost keys by the capability of detecting 3 simultaneous key-presses in
the key matrix.
The ghost key is only possible if 3 keys are pressed and held down together in a keypad
matrix. If 3 keys are reported by the STMPE1801 keypad controller, it indicates a potential
ghost key situation. The system may check for the possibility of a ghost key by analyzing the
coordinates of the 3 keys. If the 3 keys form 3 corners of a rectangle, it could be a ghost key
situation.
A ghost key may also occur in the “special function keys”. The keypad controller does not
attempt to avoid the occurrence of ghost keys. However, the system should be aware that if
more than one special function key is reported, then there is a possibility of ghost keys.
11.5.2 Key detection priority
A dedicated key is always detected, if this is enabled. When a special function key is
detected, the matrix key scanning on the same input line is disabled.
Up to 3 matrix keys can be detected. Matrix keys that fall on activated special function keys
are not counted.
As a result of these priority rules, a matrix key is ignored by the keypad controller when the
special function key on the same input line is detected, even if the matrix key is being
pressed down before the special function key. Hence, when a matrix is reported "key-down"
and it is being held down while the corresponding special function is being pressed, a "no
key" status is reported for the matrix key when the special function key is reported "keydown". If the matrix key is released while the special function key is still being held down, no
"key-up" will be reported for the matrix key. On the other hand, if the matrix key is released
after the special function key is reported "key-up", then a new "key-down" is reported for the
matrix key, followed by "key-up".
Doc ID 17884 Rev 351/60
Keypad controllerSTMPE1801
11.5.3 Keypad wakeup from Hibernate mode
The keypad controller is functional in Hibernate mode as long as it is enabled before
entering the Hibernate mode. It will then wake the system up into operational mode if a valid
key press is detected.
An asynchronous detection of the keypad column input activity is turned on during the
Hibernate mode. If any key activity is detected, the system wakes up into operational mode
for the de-bouncing of the key press to take place. If a valid key is detected, the system
stays in operational mode; otherwise, the device goes back into Hibernate mode.
The keypad controller (KPC) can be programmed to exit from Hibernate mode if a unique
combination keys is detected. These combination keys of up to 3 keys are specified in the
KPC combination set 0-2 registers.
There are 2 combination key operation modes. The modes can be set in the
COMB_KEY_MODE in the KPC_CTRL_HIGH register. In ‘OR’ mode, the device exits from
Hibernate mode on ANY of the 3 keys specified in the KPC combination set 0-2 registers. In
‘AND’ mode, the device exits from Hibernate mode ONLY if ALL of the 3 keys are pressed.
The sequence of the key pressed in not relevant as long as the 1-3 keys specified in the
KPC_COMB_KEY registers are detected, the KPC will exit from Hibernate mode and
interrupt the host. All the "active" keys must be pressed and held together, for the combi-key
interrupt to be generated.
If any other keys (beside those specified in the KPC_COMB_KEY_N registers) are pressed,
it would be considered an invalid combination and no interrupt will be generated.
52/60Doc ID 17884 Rev 3
STMPE1801Miscellaneous features
12 Miscellaneous features
12.1 Reset
The STMPE1801 is equipped with an internal POR circuit that holds the device in reset
state, until the clock is steady and V
filter with minimum 180 ns at 1.8 V V
STMPE1801 by asserting the RSTB pin. The reset pin is also integrated with a filter of
minimum 200
µs duration and maximum 500 µs duration.
input is valid. The POR circuit is integrated with a
CC
. The host system may choose to reset the
CC
Doc ID 17884 Rev 353/60
Package mechanical dataSTMPE1801
13 Package mechanical data
In order to meet environmental requirements, ST offers these devices in different grades of
ECOPACK
specifications, grade definitions and product status are available at: www.st.com.
ECOPACK
Figure 10. Package outline for Flip-chip CSP 25 (2.03 x 2.03 mm) - 0.4 mm pitch
®
packages, depending on their level of environmental compliance. ECOPACK®
®
is an ST trademark.
54/60Doc ID 17884 Rev 3
STMPE1801Package mechanical data
Table 15.Package mechanical data for Flip-chip CSP 25 (2.03 x 2.03 mm)
0.4 mm pitch
Millimeters
Symbol
MinTypMax
A0.550.6050.660
A10.170.2050.24
A20.380.40.42
b0.2150.2550.295
D1.9722.03
D1-1.6-
E1.9722.03
E1-1.6-
e0.360.40.44
f0.1900.2000.210
ccc-0.050.05
Figure 11. Footprint recommendation
Doc ID 17884 Rev 355/60
Package mechanical dataSTMPE1801
Figure 12. Device marking
)DENTIFICATIONFOR
DEVICEFRONTEND
ANDBACKENDPLANT
Figure 13. Carrier tape information
6,.
977
'
)DENTIFICATIONFOR
(ALOGENFREE
)DENTIFICATIONFOR
TRACEABLEDATECODE
!-6
1. Pin A1 is at top left corner based on above tape orientation.
56/60Doc ID 17884 Rev 3
STMPE1801Package mechanical data
Table 16.Carrier tape specifications
Millimeters
Symbol
MinTypMax
A02.062.112.16
B02.062.112.16
K00.640.690.74
F3.453.503.55
W7.908.008.30
P21.952.002.05
P03.904.004.10
10P039.8040.0040.20
D01.501.551.60
T0.1850.2000.215
P3.904.004.10
Table 17.Tape width (millimeters)
ANW1W2W3
Tape width
maxminmaxmaxminmax
8180608,414.47.910.9
Doc ID 17884 Rev 357/60
Package mechanical dataSTMPE1801
Figure 14. Reel drawing (front)
Figure 15. Reel drawing (back)
58/60Doc ID 17884 Rev 3
STMPE1801Revision history
14 Revision history
Table 18.Document revision history
DateRevisionChanges
15-Nov-20101Initial release.
13-Dec-20102Updated: Figure 12 and added footnote related to Figure 13.
09-Mar-20113Updated: Pin A1 function in Ta b le 2 and Section 12.1.
Doc ID 17884 Rev 359/60
STMPE1801
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.