315 of 323
ZBasic System Library 305 ZX Microcontroller Family 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, ZX-24r, ZX-24s Interrupt Port/Bit Pin 0 Port C, Bit 6 6 1 Port C, Bit 1 11 2 Port A, Bit 2 18 Interrupt Input Pins (ATmega Devices) ZX Models INT0 INT1 INT2 INT3 INT4 INT5 INT6 INT7 AIN0 AIN1 ZX-24, ZX-24a, ZX-24p, ZX-24n, ZX-24r, ZX-24s 6 11 18 - - - - - 18 - ZX-40, ZX-40a, ZX-40p, ZX-40n, ZX-40r, ZX-40s 16 17 3 - - - - - 3 4 ZX-44, ZX-44a, ZX-44p, ZX-44n, ZX-44r, ZX-44s 11 12 42 - - - - - 42 43 ZX-24e, ZX-24ae, ZX-24ne, ZX-24pe, ZX-24nu, ZX-24pu, ZX-24ru, ZX-24su 18 17 26 - - - - - 26 25 ZX-328n, ZX-328l 4 5 - - - - - - 12 13 ZX-32n, ZX-32l 32 1 - - - - - - 10 11 ZX-1281, ZX-1281n 25 26 - - 6 7 8 9 4 5 ZX-1280, ZX-1280n 43 44 45 46 6 7 8 9 4 5 ZX-128e, ZX-128ne, ZX-1281e, ZX-1281ne 12 11 10 9 16 15 14 13 18 17 ZX-328nu 5 6 - - - - - - 9 10 In the Interrupt Input Pin table above, the columns for INT2 and INT3 indicate that these interrupts are not available for the ZX-1281. That is because the corresponding I/O pins are used for serial channel Com1. For the ZX-1280, ZX-128e and ZX-1281e, INT2 and INT 3 will not be available if serial channel Com2 is in use. Also, INT0 and INT1 are not available on mega128, mega1281and mega1280-based devices when I2C channel 0 is in use since the same pins are used for the SCL and SDA signals. For native code devices, the following table lists the ISRs that may be included in your program if it invokes WaitForInterrupt(). The compiler will attempt to include only those ISRs that are required based