English
Language : 

45111 Datasheet, PDF (101/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
10 SX Special Features and Coding Tips
The following code snippet demonstrates this:
DEVICE STACKX
RESET Start
ORG $0
Interrupt
RETI
; Interrupt routine (must be at address $0)
; rest of interrupt routine goes here
Start
Main
; RTCC Rollover Interrupt Configuration
;
MOV !OPTION, #%10011111 ; Enable RTCC rollover interrupt
; RTCC inc on clock, no prescale
NOP
JMP Main
; rest of main routine goes here
The above code will cause the interrupt routine to be executed once every 256 clock cycles (when RTCC
rolls over from 255 to 0). A different return-from-interrupt command called RETIW can be used, how-
ever, to customize the time interval (cycle interval) in which the interrupt executes. RETIW, like RETI,
causes a return from the interrupt routine. RETIW has the additional effect of adding the contents of W
to the RTCC register upon return. By moving a negative number into W just before executing an
RETIW, the RTCC will be backed-off by the designated number of cycles. This method also has the
benefit of compensating for the number of cycles spent in the interrupt routine.
For example, if the interrupt routine should be executed once every 50 cycles, use the following two
lines of code in place of the RETI command in the listing above:
MOV W, #-50
RETIW
Of course, for this to work properly the interrupt routine must take 46 cycles or less (see below for cycle
bandwidth calculation). Even if the interrupt routine contained multiple paths of execution, due to com-
pare-jump instructions, and each path consumed a different number of clock cycles, the interrupt would
still execute once every 50 cycles. Table 21 – Interrupt Timing, below, demonstrates the effects on the
RTCC if the interrupt routine contained two possible paths of execution (path 1 is 28 cycles and path 2 is
15 cycles):
SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc. • Page 101