278 of 286
264 Interrupt Priority (highest to lowest) Interrupt 0 Interrupt 1 Interrupt 2 Analog Comparator Interrupt Interrupt 3 Interrupt 4 Interrupt 5 Interrupt 6 Interrupt 7 Pin Change Interrupt, Port A Pin Change Interrupt, Port B Pin Change Interrupt, Port C Pin Change Interrupt, Port D Pin Change Interrupt, Port E Pin Change Interrupt, Port J Pin Change Interrupt, Port K Note that a task awaiting an interrupt will exhibit some latency between the occurence of the interrupt and when the waiting task begins execution. The latency depends on a number of factors including the specific instruction being executed at the time of the interrupt and the number and frequency of system interrupts that need to be handled. Instructions that may take a long time to execute such as OutputCapture(), ShiftIn(), ShiftOut(), X10Cmd(), etc. will introduce more latency than simple instructions like assigning a value to a variable. Examples Call WaitForInterrupt(zxPinChange) Call WaitForInterrupt(zxPinRisingEdge, WaitInt2) Call WaitForInterrupt(&H40, WaitPinChangeA) ' await a change on Port A, bit 6 Resource Usage Only one task can be awaiting each interrupt at any particular time. If a task is already awaiting the specified interrupt, another call to WaitForInterrupt() for that same interrupt will return immediately. Also, on the ZX-24 the interrupt pins are common with I/O pins as shown in the table below. This means that you should set the corresponding pin to be an input (either tri-state or pull-up) when you want to use WaitForInterrupt(). Note, however, that if the pin is an output and a task is awaiting an interrupt, a transition on the corresponding output can generate the interrupt for the waiting task. This may be of use in special situations as a “software interrupt”. Interrupt and I/O Pin Sharing for ZX-24, ZX-24a, ZX-24p, ZX-24n Interrupt Port/Bit Pin 0 Port C, Bit 6 6 1 Port C, Bit 1 11 2 Port A, Bit 2 18