UM10310_1 © NXP B.V. 2008. All rights reserved.
User manual Rev. 01 — 1 December 2008 100 of 139
NXP Semiconductors UM10310
P89LPC9321 User manual
14. Keypad interrupt (KBI)
The Keypad Interrupt function is intended primarily to allow a single interrupt to be
generated when Port 0 is equal to or not equal to a certain pattern. This function can be
used for bus address recognition or keypad recognition. The user can configure the port
via SFRs for different tasks.
There are three SFRs used for this function. The Keypad Interrupt Mask Register
(KBMASK) is used to define which input pins connected to Port 0 are enabled to trigger
the interrupt. The Keypad Pattern Register (KBPATN) is used to define a pattern that is
compared to the value of Port 0. The Keypad Interrupt Flag (KBIF) in the Keypad Interrupt
Control Register (KBCON) is set when the condition is matched while the Keypad
Interrupt function is active. An interrupt will be generated if it has been enabled by setting
the EKBI bit in IEN1 register and EA = 1. The PATN_SEL bit in the Keypad Interrupt
Control Register (KBCON) is used to define equal or not-equal for the comparison.
In order to use the Keypad Interrupt as an original KBI function like in the 87LPC76x
series, the user needs to set KBPATN = 0FFH and PATN_SEL = 0 (not equal), then any
key connected to Port0 which is enabled by KBMASK register is will cause the hardware
to set KBIF = 1 and generate an interrupt if it has been enabled. The interrupt may be
used to wake-up the CPU from Idle or Power-down modes. This feature is particularly
useful in handheld, battery powered systems that need to carefully manage power
consumption yet also need to be convenient to use.
In order to set the flag and cause an interrupt, the pattern on Port 0 must be held longer
than 6 CCLKs
Table 90. Keypad Pattern register (KBPATN - address 93h) bit allocation
Bit 76543210
Symb ol KBPATN .7 KBPAT N.6 KB PATN.5 K BPATN. 4 KBPATN .3 KBPATN .2 KB PATN.1 KB PATN.0
Reset11111111
Table 91. Keypad Pattern register (KBPATN - address 93h) bit description
Bit Symbol Access Description
0:7 KBPATN.7:0 R/W Pattern bit 0 - bit 7
Table 92. Keypad Control register (KBCON - address 94h) bit allocation
Bit 76543210
Symbol------PATN_SELKBIF
Resetxxxxxx00
Table 93. Keypad Control register (KBCON - address 94h) bit description
Bit Symbol Access Description
0 KBIF R/W Keypad Interrupt Flag. Set when Port 0 matches user defined conditions specified in KBPATN,
KBMASK, and PATN_SEL. Needs to be cleared by software by writing logic0.
1 PATN_SEL R/W Pattern Matching Polarity selection. When set, Port 0 has to be equal to the user-defined
Pattern in KBPATN to generate the interrupt. When clear, Port 0 has to be not equal to the
value of KBPATN register to generate the interrupt.
2:7 - - reserved