![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
november 2010 doc id 17747 rev 1 1/19 AN3245 application note a hardware and software guid e for the stmpe1801 xpander logic? 18-bit enhanced port ex pander 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 (i 2 c). it offers the flex ibility 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 logic tm 18-bit enhanced port expander with keypad controller , datasheet, which is necessary for the succe ssful 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. www.st.com
contents AN3245 2/19 doc id 17747 rev 1 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 AN3245 list of figures doc id 17747 rev 1 3/19 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 hardware AN3245 4/19 doc id 17747 rev 1 1 hardware 1.1 external components 1.1.1 typical app lication circuit figure 1. typical application schematic note: recommended connection at rstb is bas ed 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 ! - v 6 # # 3 # , 3 $ ! ) . 4 " 2 3 4 " ' . $ 6 n 6 3 4 - 0 % 3 $ ! 3 # , ) . 4 " 2 3 4 " 2 2 2 2 # ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n 6 # # 3 # , 3 $ ! ) . 4 " 2 3 4 " ' . $ 6 n 6 3 4 - 0 % 3 $ ! 3 # , ) . 4 " 2 3 4 " 2 2 2 2 # ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y 2 o w + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / ' 0 ) / + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n + e y # o l u m n AN3245 hardware doc id 17747 rev 1 5/19 1.1.2 rstb pin recommendation 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. figure 2. rstb connectivity recommendation 1 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. figure 3. rstb connectivity recommendation 2 ! - v 2 3 4 " 6 # # 6 n 6 2 3 4 " 6 # # 3 4 - 0 % am0 8 414v1 r s tb vcc 1.65 v ? 3 .6 v s tmpe1 8 01 cpu control 10 k r s tb vcc cpu control hardware AN3245 6/19 doc id 17747 rev 1 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. figure 4. rstb connectivity recommendation 3 1.1.3 intb pin recommendation 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. 1.2 power sequence (fail safe) 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 pull- up supply on (for scl/sda/intb) or driven (for rstb) before stmpe1801 vcc turns on. 1.3 gpio output configurations 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 . ! - v 2 3 4 " 6 # # 6 n 6 3 4 - 0 % 2 3 4 " 6 # # AN3245 hardware doc id 17747 rev 1 7/19 1.3.1 push-pull set the gpio to output state through the gpio_set_dir (0x19 - 0x1b) register. input path is disabled. output path is enabled in push-pull configuration. figure 5. gpio push-pull configuration 1.3.2 open drain gpio output driven low by stmpe1801 set the gpio to output state through the gpio_set_dir (0x19 - 0x1b) register. input path is disabled. set the output state to low through the gpio_clr (0x13 - 0x15) register. output path is enabled and gpio pin pulled low. figure 6. gpio open drain configuration (output low) gpio output pulled high by external pull-up resistor set the gpio to input state through the gpio_set_dir (0x19 - 0x1b) register. input path is enabled and output path disabled. gpio is pulled high by external pull-up resistor. ! - v / 5 4 0 5 4 ) . 0 5 4 ' 0 ) / x e n a b l e d d i s a b l e d 3 4 - 0 % / 5 4 0 5 4 ) . 0 5 4 ' 0 ) / x e n a b l e d d i s a b l e d 3 4 - 0 % ! - v / 5 4 0 5 4 ) . 0 5 4 e n a b l e d d i s a b l e d % x t e r n a l p u l l u p ' 0 ) / , / 7 ' 0 ) / x 6 # # 3 4 - 0 % / 5 4 0 5 4 ) . 0 5 4 e n a b l e d d i s a b l e d % x t e r n a l p u l l u p ' 0 ) / , / 7 ' 0 ) / x 6 # # 3 4 - 0 % hardware AN3245 8/19 doc id 17747 rev 1 figure 7. gpio open drain configuration (output high) 1.4 keypad controller (kpc) the integrated keypad controller (kpc) in the stmpe1801 is configurable to the following 3 types of keys: 1. up to 10x8 (80) matrix keys 2. up to 8 special function keys 3. up to 4 dedicated keys ! - v / 5 4 0 5 4 ) . 0 5 4 d i s a b l e d e n a b l e d % x t e r n a l p u l l u p ' 0 ) / ( ) ' ( ' 0 ) / x 6 # # 3 4 - 0 % / 5 4 0 5 4 ) . 0 5 4 d i s a b l e d e n a b l e d % x t e r n a l p u l l u p ' 0 ) / ( ) ' ( ' 0 ) / x 6 # # 3 4 - 0 % AN3245 hardware doc id 17747 rev 1 9/19 1.4.1 matrix keys and special function keys the following is the configuration of the maximum 10x8 (80) matrix keys and 8 special function keys. when any of the special function keys are pressed, the matrix keys of the corresponding row are not detected. for example, when special function key 1 (skey1) is pressed and held, all the matrix keys on row 0 (key1- key10) are not detected. please refer to section 1.4.4 for care and handling of ghost keys. figure 8. matrix keys and special function keys configuration ! - v . h \ . h \ . h \ . h \ . h \ . h \ . h \ . h \ * 3 , 2 & |