Start Back Next End
  
ZBasic System Library
340
ZBasic Microcontrollers
example, if the mode value is &H21, a pin change interrupt will be generated if either bit 0 or bit 5 of the
specified port changes state.  Clearly, a mode value of zero is useless since no pin change interrupt can
ever occur in that case.  See the Resource Usage sub-section Pin Change Interrupts for information on
the available pin change interrupts for each target device.
Pin Change Interrupts (ATxmega targets)
For ATxmega target devices, a task may await a state change on one or more pins of an I/O port.  Each
port has two separate channels of pin-change detection, e.g. WaitPinChangeA0 and
WaitPinChangeA1 both sensitive to pin changes on Port A.  The port and channel are specified via the
intNum parameter and the mode parameter contains a bit mask indicating the bits of interest.  For
example, if the mode value is &H21, a pin change interrupt will be generated if either bit 0 or bit 5 of the
specified port changes state.  Clearly, a mode value of zero is useless since no pin change interrupt can
ever occur in that case.  See the Resource Usage sub-section Pin Change Interrupts for information on
the available pin change interrupts for each target device.
By default, each pin that is enabled for a pin change interrupt will trigger the interrupt on either edge.  You
may configure the sensitivity for each individual pin to trigger an interrupt on either edge, rising edge only,
falling edge only or a low level.  The setting for each pin change sensitivity is made in a “pin control”
register specific to that pin.  For example, the pin control register for bit 3 of port C is named
PORTC_PIN3CTRL.  Consult the applicable ATxmega datasheet for more information on these registers.
Analog Comparator Interrupt (ATtiny and ATmega targets)
A task may await an analog comparator interrupt by specifying the value waitAnalogComp (&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.
With all of the mode values in the table above, the analog comparator’s positive input is AIN0 and the
comparator’s negative input is either AIN1 or, (on some target devices) if the ACME bit is set in a CPU
register (see below), the analog input specified by the multiplexor select bits in Register.ADMUX. 
Another option for the positive comparator input is to select the internal “band gap” voltage.  This voltage
level (approximately 1.23 volts) is selected by adding the value &H40 to the mode values in the table
above.   The built-in constant zxAnalogReference has this value.
See the Resource Usage sub-section Analog Comparator Interrupts for information on the location of the
AIN0 and AIN1 pins for each target device and which register contains the ACME bit (where available). 
See the section in the Atmel microcontroller documentation describing the analog comparator for further
details.
Analog Comparator Interrupt (ATxmega targets)
On xmega devices, the analog comparator has two channels and a task may await an analog comparator
interrupt on one of the analog comparator channels by giving the appropriate value for intNum.  See the
Resource Usage sub-section Analog Comparator Interrupts for information on the selector values and the
number of analog comparators supported for individual xmega devices.
 
In order to use any of the analog comparator interrupts, you must first configure positive and negative
inputs to the corresponding comparator(s) using the processor registers ACA_AC0MUXCTRL,
ACA_AC1MUXCTRL, ACB_AC0MUXCTRL and/or ACB_AC1MUXCTRL.  Also, the high speed/low power
control bit and the hysteresis control bits in the ACA_AC0CTRL, ACA_AC1CTRL, ACB_AC0CTRL and
Previous page Top Next page