Xmega Application Note


pmic_example.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00051 #include "avr_compiler.h"
00052 #include "pmic_driver.h"
00053 
00055 volatile uint8_t compareMatchCCount = 0;
00056 
00058 volatile uint8_t compareMatchBCount = 0;
00059 
00061 volatile uint8_t compareMatchACount = 0;
00062 
00063 
00064 
00069 ISR(TCC0_CCA_vect)
00070 {
00071         ++compareMatchACount;
00072 }
00073 
00074 
00075 
00080 ISR(TCC0_CCB_vect)
00081 {
00082         ++compareMatchBCount;
00083 }
00084 
00085 
00086 
00091 ISR(TCC0_CCC_vect)
00092 {
00093         ++compareMatchCCount;
00094 }
00095 
00096 
00097 
00113 int main( void )
00114 {
00115         /* Enable all interrupt levels. */
00116         PMIC_SetVectorLocationToApplication();
00117         PMIC_EnableLowLevel();
00118         PMIC_EnableMediumLevel();
00119         PMIC_EnableHighLevel();
00120         sei();
00121 
00122         /* Set up Timer/Counter 0 with three Compare Match interrupts. */
00123         TCC0.CTRLB = TC0_CCCEN_bm | TC0_CCBEN_bm | TC0_CCAEN_bm | TC_WGMODE_NORMAL_gc;
00124         TCC0.INTCTRLB = (uint8_t) TC_CCCINTLVL_HI_gc | TC_CCBINTLVL_MED_gc | TC_CCAINTLVL_LO_gc;
00125         TCC0.PER = 0xff; /* Period: 0xff */
00126         TCC0.CCA = 0x60; /* Compare Match A, will need to wait for both Compare Match C and B. */
00127         TCC0.CCB = 0x50; /* Compare Match B, will be interrupted by higher level Compare Match C. */
00128         TCC0.CCC = 0x70; /* Compare Match C. */
00129 
00130         TCC0.CTRLA = TC_CLKSEL_DIV1_gc; /* Run at maximum speed. */
00131 
00132         while(true) {
00133         }
00134 }
@DOC_TITLE@
Generated on Wed Apr 23 07:41:39 2008 for AVR1305 XMEGA Interrupts and the Programmable Multi-level Interrupt Controller by doxygen 1.5.5