Detecting a Positive Edge by Polling ACI

This part of the code shows a far more secure and flexible way of detecting a positive edge on the comparator output. Even though the Analog Comparator Interrupt is disabled, the interrupt flag will still be set when events on the comparator output matches the settings of the ACIS1/ACIS0 bits in ACSR. E.g., a positive edge will always set the ACI bit in ACSR if ACIS1/ACIS0 both are one (refer to the datasheet for details). The ACI flag will reflect whether the event to look for has occurred since the last ACI Reset. In this application note, positive edge detection by polling ACI is implemented according to the following procedure:

Setup
  1. 1.Set ACIS0 and ACIS1 = 1.
Polling
  1. 1.Clear the ACI bit by writing a logical "1" to it.
  2. 2.Wait until ACI goes high.
Figure 1. ACI Polling Flow Chart
Table 1. ACI Polling Performance Figures
Parameter Value
Code Size (Words) 5
Initialization Time (Cycles) 2
Response Time (Cycles) 3 - 5
Register Usage Low Registers: None
High Registers: None
Pointers: None
Interrupts Usage None
Peripherals Usage Analog Comparator