28
Port J Key Wakeup Interrupt:
Operation
The Port J key Wakeup Interrupt is a more powerful version of the Port H Key Wakeup
Interrupt. Unlike the Port H Key Wakeup, Port J can be set to trigger on either a
rising edge or a falling edge input. This adds to the flexibility of the key
wakeup but also adds to the complexity.
The selection of which bits will be used to generate interrupts is controlled by
_H12KWIEJ. As with port H, when a bit is set to 1, the Key Wakeup for that channel
is enabled. Also as with the Port H Key Wakeup, while each bit can cause an
interrupt, they all call the same interrupt service routine.
_H12KWIEJ:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
_H12KWIFJ:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Before enabling the Key Wakeup Interrupt it is necessary to set which edge will
trigger the interrupt and to select to use either the pull-up or pulldown resistors
on the input.
Which edge will be used to trigger an interrupt is determined by the setting of
_H12KPOLJ. Writing a zero to a bit of _H12KPOLJ makes that channel falling edge
triggered. Writing a one makes the channel rising edge triggered.
_H12KPOLJ:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
The pull-up and pulldown resisters are controlled by _H12PUPSJ and _H12PULEJ.
_H12PUPSJ selects between using pull-up resisters and pulldown resisters. When a
bit in _H12PUPSJ is set to one, the channel has a pull-up resistor. When the bit
is zero, there is a pulldown resistor on the input. This MUST be set before the
pull-up/pulldown resistors are enabled. _H12PULEJ is used to enable the pull-up or
pulldown resistor. Writing a one enables the pull-up or pulldown, while writing a
zero will disable it.
_H12PULEJ:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
_H12PUPSJ:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
As with the Port H Key Wakeup, the flags are cleared after a Port J Key Wakeup
Interrupt is triggered. This is done by writing a one to the bits in _H12KWIFJ
that have been set.
Sample Code
This code sets up the Port J Key Wakeup for falling edge operation on all 8
channels and enables the pull up resistors for all the bits.
_
_mod2_
_ void KeyJ(void);
// function prototype