mg84fl54 Megawin Technology, mg84fl54 Datasheet - Page 58

no-image

mg84fl54

Manufacturer Part Number
mg84fl54
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
14. Keypad Interrupt
The Keypad Interrupt function is intended primarily to allow a single interrupt to be generated when Port 1 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 related to 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 by hardware when the condition is matched. An interrupt will
be generated if it has been enabled by setting the EKBI bit in AUXIE register and EA=1. The PATN_SEL bit (in
KBCON) is used to define “equal” or “not-equal” for the comparison.
In order to use the Keypad Interrupt as the “Keyboard” Interrupt, the user needs to set KBPATN=0xFF and
PATN_SEL=0 (not equal). Then, any key connected to Port 0 which is enabled by KBMASK register will cause
the hardware to set KBIF and generate an interrupt if it has been enabled. The interrupt may wake up the CPU
from Idle or Power down modes.
14.1. Keypad Register
The following special function registers are related to the KBI operation:
KBPATN (Address=D5H, Keypad Pattern Register)
KBPATN.7-0: The keypad pattern, reset value is 0xFF.
KBCON (Address=D6H, Keypad Control Register)
PATN_SEL: Pattern Matching Polarity selection.
When set, Port 0 has to be
When clear, Port 0 has to be
KBIF: Keypad Interrupt Flag.
Set when Port 0 matches user defined conditions specified in KBPATN, KBMASK, and PATN_SEL. Needs to be
cleared by firmware by writing “0”.
KBMASK (Address=D7H, Keypad Interrupt Mask Register)
KBMASK.7: When set, enables P0.7 as a cause of a Keypad Interrupt.
KBMASK.6: When set, enables P0.6 as a cause of a Keypad Interrupt.
KBMASK.5: When set, enables P0.5 as a cause of a Keypad Interrupt.
KBMASK.4: When set, enables P0.4 as a cause of a Keypad Interrupt.
KBMASK.3: When set, enables P0.3 as a cause of a Keypad Interrupt.
KBMASK.2: When set, enables P0.2 as a cause of a Keypad Interrupt.
KBMASK.1: When set, enables P0.1 as a cause of a Keypad Interrupt.
KBMASK.0: When set, enables P0.0 as a cause of a Keypad Interrupt.
KBMASK.7 KBMASK.6 KBMASK.5 KBMASK.4 KBMASK.3 KBMASK.2 KBMASK.1 KBMASK.0
KBPATN.7 KBPATN.6 KBPATN.5 KBPATN.4 KBPATN.3 KBPATN.2 KBPATN.1 KBPATN.0
58
7
7
7
-
6
6
6
-
equal
not equal
5
5
5
-
to the user-defined Pattern in KBPATN to generate the interrupt.
to the value of KBPATN register to generate the interrupt.
MG84FL54B Data Sheet
4
4
4
-
3
3
3
-
2
2
2
-
PATN_SEL
1
1
1
KBIF
0
0
0
MEGAWIN

Related parts for mg84fl54