© 2000 Scenix Semiconductor, Inc. All rights reserved.
- 22 -
www.scenix.com
SX48BD/SX52BD/SX52BD75/SX52BD100
6.2
Port B MIWU/Interrupt Configuration
The WKPND_B register comes up with a random value
upon reset. The user program must clear the register
prior to enabling the wake-up condition or interrupts. The
proper initialization sequence is:
1. Select the desired edge (through WKED_B register).
2. Clear the WKPND_B register.
3. Enable the Wakeup condition (through WKEN_B regis-
ter).
Below is an example of how to read the WKPND_B regis-
ter to determine which Port B pin caused the wakeup or
interrupt, and to clear the WKPND_B register:
The final mov instruction in this example performs an
exchange of data between the working register (W) and
the WKPND_B register. This exchange occurs only with
accesses to the WKPND_B and CMP_B registers. Other-
wise, the mov instruction does not perform an
exchange, but only moves data from the source to the
destination.
Here is an example of a program segment that config-
ures the RB0, RB1, and RB2 pins to operate as Multi-
Input Wakeup/Interrupt pins, sensitive to falling edges:
To prevent false interrupts, the enabling step (clearing
bits in WKEN_B) should be done as the last step in a
sequence of Port B configuration steps.
After this program segment is executed, the device can
receive interrupts on the RB0, RB1, and RB2 pins. If the
device is put into the power down mode (by executing a
SLEEP instruction), the device can then receive wakeup
signals on those same pins.
mov
W, #$19 ;prepare to exchange WKPND_B
;with W (can also use $09)
mov
M, W
clr
W
mov
!RB,W
;W contains WKPND_B
;contents of W exchanged
;with contents of WKPND_B
mov
mov
W,#$1F
M,W
;prepare to write port data
;direction registers
mov W,#$07
;load W with the value 07h
mov !RB,W
;configure RB0-RB2 to be inputs
mov
mov
W,#$1A
M,W
;prepare to write WKED_B
;(edge) register
mov W,#$07
;load W with the value 07h
mov !RB,W
;configure RB0-RB2 to sense
;falling edges
mov W,#$19
;prepare to access WKPND_B
mov M,W
;(pending) register
mov W,#$00
;clear W
mov !RB,W
;clear all wakeup pending flags
mov
mov
W,#$1B
M,W
;prepare to write WKEN_B (enable)
;register
mov W,#$F8
;load W with the value F8h
mov !RB,W
;enable RB0-RB2 to operate as
;wakeup inputs