AN3245
Application note
A hardware and software guide for the STMPE1801 Xpander Logic™ 18-bit enhanced port expander with keypad controller
Introduction
The STMPE1801 is a GPIO (general purpose input/output) port expander able to interface a main digital ASIC via a two-line bidirectional bus (I2C). It offers the flexibility to be configured into a 10x8 matrix keypad controller for QWERTY keyboards and general purpose inputs/outputs.
This document highlights the guidelines and information complementary to the STMPE1801; Xpander LogicTM 18-bit enhanced port expander with keypad controller, datasheet, which is necessary for the successful design of STMPE1801 in applications.
The first part of the document highlights information on the hardware including external components/connectivity, power, etc.
The second part of the document focuses on information regarding the software, in which programming sample codes are shown.
November 2010 |
Doc ID 17747 Rev 1 |
1/19 |
www.st.com
Contents |
AN3245 |
|
|
Contents
1 |
Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
4 |
|
1.1 External components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
4 |
1.1.1 Typical application circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1.2 RSTB pin recommendation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1.3 INTB pin recommendation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 |
Power sequence (fail safe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
6 |
|
1.3 |
GPIO output configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
6 |
|
|
1.3.1 |
Push-pull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
7 |
|
1.3.2 |
Open drain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
7 |
1.4 Keypad controller (KPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.1 Matrix keys and special function keys . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4.2 Dedicated keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.4.3 Combination keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.4.4 Ghost keys handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
|
1.5 |
Key column/row pins external capacitance . . . . . . . . . . . . . . . . . . . . . . . |
12 |
2 |
Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
13 |
|
|
2.1 |
I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
13 |
2.1.1 I2C initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Programming guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2.2 Interrupt handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.2.3 Keypad press/release code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.4 Key lock with combination keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3 Hotkey de-bounce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.4 Power modes transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3 |
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
18 |
2/19 |
Doc ID 17747 Rev 1 |
AN3245 |
List of figures |
|
|
List of figures
Figure 1. Typical application schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Figure 2. RSTB connectivity recommendation 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 3. RSTB connectivity recommendation 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 4. RSTB connectivity recommendation 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 5. GPIO push-pull configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 6. GPIO open drain configuration (output low) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 7. GPIO open drain configuration (output high) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 8. Matrix keys and special function keys configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 9. Dedicated keys configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 10. Three simultaneous key presses with ghost key event . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 11. Three simultaneous key presses without ghost key event . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 12. Typical programming flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Doc ID 17747 Rev 1 |
3/19 |
Hardware |
AN3245 |
|
|
66n 6 |
'0)/ |
34-0% |
'0)/ |
|
|
'0)/ |
|
6## |
'0)/ |
|
'0)/ |
||
# |
||
'0)/ |
||
|
||
|
'0)/ |
|
2 |
'0)/ |
|
234" |
|
|
2 |
'0)/ |
|
).4" |
||
|
||
2 |
'0)/ |
|
3#, |
'0)/ |
|
2 |
||
'0)/ |
||
3$! |
||
3$! |
'0)/ |
|
3#, |
'0)/ |
|
).4" |
'0)/ |
|
234" |
'0)/ |
|
'.$ |
'0)/ |
|
|
'0)/ |
+EY 2OW +EY 2OW +EY 2OW +EY 2OW +EY 2OW +EY 2OW +EY 2OW +EY 2OW
+EY #OLUMN +EYY#OLUMN +EY #OLUMN +EYY#OLUMN +EY #OLUMN +EYY#OLUMN +EY #OLUMN +EY #OLUMN +EY #OLUMN +EYY#OLUMN
!-V
Note: |
Recommended connection at RSTB is based on the use of Baseband/CPU GPIO as the |
|
control signal. |
In a typical application, the following external components are required:
●R1: 10 kΩ pull-up resistor at RSTB
●R2: 2.2 kΩ - 10 kΩ pull-up resistor at INTB
●R3: 2.2 kΩ - 10 kΩ pull-up resistor at SCL (It is recommended that Vpullup ≥ VCC)
●R4: 2.2 kΩ - 10 kΩ pull-up resistor at SDA (It is recommended that Vpullup ≥ VCC)
●C1: 100 nF capacitor at VCC
4/19 |
Doc ID 17747 Rev 1 |
AN3245 |
Hardware |
|
|
The following is a few examples of configurations at RSTB depending on applications.
●If a reset delay is desired (recommended) upon power up, an RC delay can be connected to the RSTB as shown below.
6 n 6
34-0%
6##
234"
!-V
●If external reset assertion is required through CPU/baseband, RSTB can be connected to the GPIO. The diagram below shows the presence of a weak pull-up resistor assuming CPU/baseband control is open drain.
1.65 V – 3.6 V
STMPE1801
VCC
10 kΩ
CPU control
RSTB
AM08414v1
Doc ID 17747 Rev 1 |
5/19 |
Hardware |
AN3245 |
|
|
●If reset delay and external reset assertion, as shown in case1 and case2 above, are not required, it is recommended to short the RSTB pin to VCC through a resistor.
6 n 6
34-0%
6##
234"
!-V
The INTB pin is programmable to active low or active high. When programmed to active low, a pull-up resistor of 2.2 kΩ -10 kΩ is required. When programmed to active high, a pull-down resistor of 2.2 kΩ - 10 kΩ is required.
If the INT signal is not in use, it is necessary to pull the INTB pin to VCC.
All GPIO pins of the STMPE1801 are NOT fail safe. This means that it is necessary to make sure that VCC supply to STMPE1801 is first turned on before driving the GPIO inputs.
All other pins except GPIO are with fail safe structures. It is possible to have these pins pullup supply on (for SCL/SDA/INTB) or driven (for RSTB) before STMPE1801 VCC turns on.
The STMPE1801 provides push-pull type of GPIO output as is. If open drain GPIO outputs are required, it is configurable with a tweak to the software programming routine. See figures 5, 6, and 7.
6/19 |
Doc ID 17747 Rev 1 |