Using the Analog Comparator Interrupt

The application note program shows an example on how to enable the comparator interrupt. In the example, interrupt on comparator toggle is shown. The following procedure is followed:
  1. 1.Clear interrupt flag and ACIS1/ACIS0. The interrupt flag must be cleared first. If not, and the flag for some reason already is set, the MCU will start executing the interrupt routine immediately when the interrupts is enabled. Clearing ACIS1/ACIS0 selects interrupt on toggle.
  2. 2.Enable Global Interrupts.
  3. 3.Enable the Analog Comparator Interrupt by setting the ACIE bit in ACSR.
Note that since the ACSR Register is one of the lower 32 I/O, registers, the “SBI” instruction can be used to set, clear and test bits.
Table 1. Analog Comparator Interrupt Enable Performance Figures
Parameter Value
Code Size (Words) 4
Execution Time (Cycles) 5
Register Usage Low Registers: None
High Registers: 1
Pointers: None
Interrupts Usage None
Peripherals Usage Analog Comparator