English
Language : 

45111 Datasheet, PDF (102/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
10 SX Special Features and Coding Tips
Table 21 - Interrupt Timing
Event
1) RTCC rolls over
2) 3 cycles required to enter interrupt routine
3) Interrupt routine executes
4) –50 (206 in twos-compliment) is added to RTCC
5) RTCC rolls over again in exactly 19 additional
cycles (Path 1) or 32 additional cycles (Path 2)
Path 1
(28 cycles)
RTCC = 0
RTCC = 3
RTCC = 31
RTCC = 237
Total Cycles = 31 + 19 =
50
Path 2
(15 cycles)
RTCC = 0
RTCC = 3
RTCC = 18
RTCC = 224
Total Cycles = 18 + 32 =
50
By adjusting the value in W before the RETIW command, various amounts of cycle bandwidth will be
allocated to the main routines. Normally this won’t be a problem but care should be taken to ensure that
the RTCC doesn’t rollover too often, causing little or no cycle time to be allocated to the main routines.
If the RTCC adjustment value is too small for the size of the interrupt routine, the main routine may
eventually hang up, may not execute at all, or the interrupt routine will miss the rollover and only
execute every 256 cycles. Use the following equation as a general rule-of-thumb when determining the
minimum adjustment value:
Minimum RTCC Adjustment Value = -(max cycles for interrupt + 6)
The 6 in this equation accounts for the number of cycles required to enter the interrupt routine (3 cycles)
plus the number of additional cycles needed to complete the longest command (3 cycles extra to finish
an IREAD). If the IREAD command is not used in the main program, a value of -(maximum cycles for
interrupt + 4) is the minimum, allowing for only a single instruction in the main routine to be executed
between interrupts.
As an example, the following interrupt routine takes 4 cycles to execute:
Interrupt
MOV W, #-8
RETIW
; 1 cycle
; 3 cycles
The adjustment value of –8, which is –(max cycles for interrupt + 4), will cause the interrupt routine to
execute every 8 cycles and will only allow one single-cycle or one three-cycle instruction in the main
routine to execute between interrupts. If the main routine contained an IREAD command, however, the
main routine would execute one instruction between interrupts until it reached the IREAD, at which
point it would get eternally stuck, and only the interrupt would continue. As another example, if the
adjustment value was –7, this would be too small an adjustment and would cause the interrupt routine
to execute, but no instructions in the main routine would execute at all.
Page 102 • SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc.