English
Language : 

45111 Datasheet, PDF (93/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
10 SX Special Features and Coding Tips
The following code snippet demonstrates this:
Start
; Edge Detection Configuration
;
MODE
MOV
MODE
MOV
$0A
; Set Mode to allow Edge configuration
!rb,#%11111111 ; Port B bits 0-7 to falling edge
$0F
; Set Mode to allow Direction configuration
!rb,#%11111111 ; Port B bits 0-7 to input
Main
MODE
MOV
JMP
$09
; Set Mode for Pending register check
!rb,#%00000000 ; This line moves WKPND_B to W and
; writes all zeros to WKPND_B
Main
; At this point, W should be checked for
; high bits, indicating a falling
; edge occurred
The following are points to remember with edge detection:
• The edge detection feature is always enabled and the Pending register is always updated even if the
SX program does not configure or use it.
• It is up to the SX program to clear the bits of the Pending register when detection of a future
transition is desired. The MOV !rb, #%00000000 instruction effectively clears all bits of the Pending
register at the same time that it stores the current edge detection status in W.
• If the SX program is designed to handle only one edge detection event at a time (on two or more
pins), it will be necessary to get the status (as shown above), clear only the bit being attended to and
move the modified status back to the Pending register.
• An edge detection event will not wake up the SX chip from a SLEEP mode unless the Wake-Up
Enable mode is also set. See below for more information.
10.2.6 Wakeup (Interrupt) on Edge Detection
Every I/O pin in port B can be set to cause an interrupt upon logic level transitions (rising edge or
falling edge). By configuring interrupts on input pins, the SX chip can respond to signal changes in a
quick and deterministic fashion. In addition, an interrupt of this sort will wake up the SX chip from a
SLEEP state. This can be configured by writing to the Edge Selection register (WKED_B) and the Wake-
Up Enable register (WKEN_B) and detected by monitoring the Pending register (WKPEN_B) in the
interrupt routine. The I/O pins have interrupts disabled and are set to detect falling edge transitions by
default.
As with edge selection, the Pending register bits will never be cleared by the SX alone; the running
program is responsible for doing so. This means if a desired edge is detected, the interrupt will occur
SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc. • Page 93