This example demonstrates how to use the analog comparator driver.
The analog comparator driver is described in the Analog Comparator (AC) section.
All AVR XMEGA devices with an analog comparator (AC) can be used. This example has been tested with the following setup:
The example will configure the analog comparator B in window mode and compare the input value from PIN1 (PB1) with the bandgap voltage as lower reference and a scaled VCC as upper reference. The upper value has been chosen by best fit to match the potmeter output from ground to VCC / 2 (1.65 V).
In addition the example configures the analog comparator A two channels in single trigger level mode. On the Xplain evaluation kit these channels are available on the spare ADC/DAC/AC header.
Summary of analog comparator configuration:
This example uses the on-board LEDs to provide user feedback, the output from the LEDs are as follows:
This example depends on the following modules:
This software was written for the GNU GCC and IAR for AVR. Other compilers may or may not work.
For further information, visit Microchip.