Xmega Application Note


AC_example_polled.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00055 #include "ac_driver.h"
00056 
00057 /* The Analog comparator used in the example.*/
00058 #define AC ACA
00059 
00060 int main(void)
00061 {
00062         /* Enable Analog comparator submodule 0. */
00063         AC_Enable(&AC, ANALOG_COMPARATOR0, false);
00064 
00065         /* By defalut the Analog comparators interupt flag triggers on changes on
00066          * both edges. If another trigger setting (INTMODE) is preferd use the
00067          * AC_ConfigInterrupt function to change the settings. */
00068 
00069         /* Set up MUXes to sense pin 0 and 1. */
00070         AC_ConfigMUX(&AC, ANALOG_COMPARATOR0, AC_MUXPOS_PIN0_gc, AC_MUXNEG_PIN1_gc);
00071 
00072         /* Set up AC with a small hysteresis. */
00073         AC_ConfigHysteresis(&AC, ANALOG_COMPARATOR0, AC_HYSMODE_SMALL_gc);
00074 
00075         /* Sense for 4 changes on comparator output. */
00076         for(uint8_t i=0; i < 4; i++){
00077                 /* Wait for Comparator to change value. */
00078                 AC_WaitForComparator_Blocking(&AC, ANALOG_COMPARATOR0);
00079         }
00080 
00081         /* Disable submodule 0. */
00082         AC_Disable(&ACA, ANALOG_COMPARATOR0);
00083 
00084         do{
00085                 /* Stop here. */
00086         }while(true);
00087 }
@DOC_TITLE@
Generated on Tue Apr 22 15:13:25 2008 for AVR1302 Using the XMEGA Analog Comparator by doxygen 1.5.5