#define TIMER0_INTERRUPT_LEVEL 7 #define TIMER1_INTERRUPT_LEVEL 4 /*-----------------*/ /* Clock Selection */ /*-----------------*/ #define TC_CLKS 0x7 #define TC_CLKS_MCK2 0x0 #define TC_CLKS_MCK8 0x1 #define TC_CLKS_MCK32 0x2 #define TC_CLKS_MCK128 0x3 #define TC_CLKS_MCK1024 0x4 // +++++++++++++ Testfunktion +++++++++++++++++++++++++++++++++++++ void ereignisfunktion (void) { volatile int ereignis = 1; } //*------------------------- Internal Function -------------------------------- //*---------------------------------------------------------------------------- //* Function Name : AT91F_TC_Open //* Object : Initialize Timer Counter Channel and enable is clock //* Input Parameters : = TC Channel Descriptor Pointer //* = Timer Counter Mode //* : = Timer peripheral ID definitions //* Output Parameters : None //*---------------------------------------------------------------------------- void AT91F_TC_Open ( AT91PS_TC TC_pt, unsigned int Mode, unsigned int TimerId) //* Begin { unsigned int dummy; //* First, enable the clock of the TIMER AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<< TimerId ) ; //* Disable the clock and the interrupts TC_pt->TC_CCR = AT91C_TC_CLKDIS ; TC_pt->TC_IDR = 0xFFFFFFFF ; //* Clear status bit dummy = TC_pt->TC_SR; //* Suppress warning variable "dummy" was set but never used dummy = dummy; // Einstellen des Wave-Mode und WAVSEL = 00 // TC_pt->TC_CMR = 0x1 << 15 | 0x1 << 14 | 0x1 << 13 | Mode; //* Set the Mode of the Timer Counter TC_pt->TC_CMR = Mode ; //* Enable the clock TC_pt->TC_CCR = AT91C_TC_CLKEN ; //* End } void timer_init ( void ) //* Begin { //* Open timer0 AT91F_TC_Open(AT91C_BASE_TC0, TC_CLKS_MCK1024, AT91C_ID_TC0); //* Open Timer 0 interrupt AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_TC0, TIMER0_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE, ereignisfunktion ); AT91C_BASE_TC0->TC_IER = AT91C_TC_CPCS; // IRQ enable CPC // AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_TC0); //* Start timer0 AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG ; }