276 of 286
262 WaitForInterrupt Type Subroutine Invocation WaitForInterrupt(mode) WaitForInterrupt(mode, intNum) Parameter Method Type Description mode ByVal Byte A value specifying what action will trigger the interrupt. See the discussion below. intNum ByVal Byte A designator for the interrupt to await (see discussion below). Discussion This routine allows a task to suspend itself and wait for an interrupt. The particular interrupt awaited depends on the intNum designator combined with the mode value. There are three general sources of interrupts that can be awaited: external interrupts, analog comparator interrupts and pin change interrupts. External Interrupts 0-7 A task may await an external interrupt by specifying the value 0 through 7 (corresponding to external interrupts 0-7, respectively) for the intNum parameter. In this case, the allowable values for the mode parameter and their respective meanings are given in the table below. Note, however, that some devices support only a subset of the hardware interrupt channels. See the table in the Resource Usage section for details of the supported interrupt channels and the interrupt input pin for each device. Hardware Interrupt Mode Values Value Built-in Constant Interrupt Trigger &H10 zxPinLow A low level on the interrupt pin. &H14 zxPinChange Any logic level change on the interrupt pin. &H18 zxPinFallingEdge A high to low transition on the interrupt pin. &H1C zxPinRisingEdge A low to high transition on the interrupt pin. All other values are reserved for future use. For compatibility with BasicX, there are similarly named built- in constants that begin with the prefix bx instead of zx except that there is no equivalent for zxPinChange. Additionally, on mega32-based devices, Interrupt 2 is not capable of the first two trigger modes; it can only be triggered on a rising edge or a falling edge. The built-in constants WaitInt0 through WaitInt7 may be used to specify the intNum parameter. If no intNum parameter is given, Interrupt 1 is assumed (for compatibility with BasicX). This is equivalent to using WaitForInterrupt(mode, 1). Analog Comparator Interrupt A task may await an analog comparator interrupt by specifying the value &H10 for intNum. The corresponding built-in constant is waitAnalogComp. In this case, the mode parameter specifies the comparator output transition that will cause the interrupt to occur. Analog Comparator Interrupt Mode Values Value Built-in Constant Interrupt Trigger &H00 zxAnalogCompChange Comparator output rising edge or falling edge. &H02 zxAnalogCompFalling Comparator output falling edge. &H03 zxAnalogCompRising Comparator output rising edge.