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:
- 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.
- Enable Global Interrupts.
- 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 3-1. Analog Comparator Interrupt Enable Performance FiguresParameter | 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 |