void timer1_c_irq_handler (void)
{
unsigned int dummy;
dummy = AT91C_BASE_TC1->TC_SR;
dummy = dummy;
T_Counter++;
AT91C_BASE_TC1->TC_CCR |= AT91C_TC_CLKEN | AT91C_TC_SWTRG;
AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
AT91F_PIO_SetOutput(AT91C_BASE_PIOA, AT91C_PIO_PA2); //Normal work LED notification
delay_ms(500);
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, AT91C_PIO_PA2);
}
int main (void)
{
unsigned int dummy ;
AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, AT91C_PIO_PA2); //LED 1
AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, AT91C_PIO_PA3); //LED 2
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_TC1; // Enable peripheral clock
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS; // Disable TC clock
AT91C_BASE_TC1->TC_IDR = 0xFFFFFFFF; // Disable interrupts
dummy = AT91C_BASE_TC1->TC_SR; // Clear status register
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK | AT91C_TC_CPCTRG; // Set mode
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN ; // Enable the Clock counter
AT91C_BASE_TC1->TC_IER = AT91C_TC_CPCS;
AT91C_BASE_AIC->AIC_IDCR = 0x1 << AT91C_ID_TC1;
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC1] = (unsigned int) timer1_c_irq_handler;
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC1] = AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 4 ;
AT91C_BASE_AIC->AIC_ICCR = 0x1 << AT91C_ID_TC1;
AT91C_BASE_AIC->AIC_IECR = 0x1 << AT91C_ID_TC1;
AT91C_BASE_TC1->TC_RC = 23961;
AT91C_BASE_TC1->TC_CCR = AT91C_TC_SWTRG;
while(1)
{
AT91F_PIO_SetOutput(AT91C_BASE_PIOA, AT91C_PIO_PA3); //Normal work LED notification
delay_ms(100);
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, AT91C_PIO_PA3);
Func1(); /*first function */
AT91F_PIO_SetOutput(AT91C_BASE_PIOA, AT91C_PIO_PA4); //Normal work LED notification
delay_ms(100);
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, AT91C_PIO_PA4);
Func2(); /*second function */
}
}