[U-Boot-Users] AT91RM9200 Timer 0 Interrupt never gets generated.

Balajee Premraj balajee at a-k-a.net
Thu Aug 23 16:31:55 CEST 2007


Hi all,

I am trying to enable the timer 0 interrupt for the AT91RM9200EK
reference board.

Although the timer keeps running, its not generating interrupt, I
enabled all the timer0 interrupts to ensure at least I get some
interrupts being generated, but basically my interrupt routine never
gets called.

I verified the status of the registers 

aic_svr17  ---> Register contains the correct address of the irq
function.(verifed through system.map file)
aic_imr = 0x00020000  ---> The timer-0 interrupt is enabled.
tc0_imr = 0xff        ---> all timer interrupts are enabled.
pmc_pcsr: 0x01022000  ---> corresponding peripheral clock is enabled.

But the IRQ function never gets called.
(I use another test routine to read the counter value, the counter value
is always zero)


Thanks,Balajee

#ifdef CONFIG_TIMER_INTERRUPTS
static void get_timer_irq(void);
#endif
int interrupt_init (void)
{
        unsigned short value;
        tmr = AT91C_BASE_TC0;

        /* enables TC1.0 clock */
        *AT91C_PMC_PCER = 1 << AT91C_ID_TC0;  /* enable clock */

        *AT91C_TCB0_BCR = 0;
        *AT91C_TCB0_BMR = AT91C_TCB_TC0XC0S_NONE |
AT91C_TCB_TC1XC1S_NONE | AT91C_TCB_TC2XC2S_NONE;
        tmr->TC_CCR = AT91C_TC_CLKDIS;
#define AT91C_TC_CMR_CPCTRG (1 << 14)
        /* set to MCLK/2 and restart the timer when the vlaue in TC_RC
is reached */
        tmr->TC_CMR = AT91C_TC_TIMER_DIV1_CLOCK | AT91C_TC_CMR_CPCTRG;

#ifdef CONFIG_TIMER_INTERRUPTS

        /* Clear status */
        value = tmr->TC_SR ;
        AT91PS_AIC pAic = AT91C_BASE_AIC;

        /* Disable the timer interrupt */
        pAic->AIC_IDCR = 1 << AT91C_ID_TC0;
        /* Program SVR and SMR */
        pAic->AIC_SVR[AT91C_ID_TC0] = (unsigned int) &get_timer_irq;
        pAic->AIC_SMR[AT91C_ID_TC0] =
AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE |AT91C_AIC_PRIOR_HIGHEST;
         /* Clear any pending Interrupts */
        pAic->AIC_ICCR = 1 << AT91C_ID_TC0;
        /* Enable Interrupt on the timer control register */
        tmr->TC_IER = 0xFF;

#else
        tmr->TC_IDR = ~0ul;

#endif
        tmr->TC_RC = TIMER_LOAD_VAL;
        lastinc = 0;
        tmr->TC_CCR = AT91C_TC_SWTRG | AT91C_TC_CLKEN;
        timestamp = 0;


#ifdef CONFIG_TIMER_INTERRUPTS
        /* Enable interrupt */
        pAic->AIC_IECR = 1 << AT91C_ID_TC0;
#endif
        return (0);
}

#ifdef CONFIG_TIMER_INTERRUPTS
static void get_timer_irq(void)
{
        AT91PS_AIC pAic = AT91C_BASE_AIC;
        unsigned short value;
        counter++;
        /* Clear status */
        value = tmr->TC_SR ;
        /* clear all interrupts */
        pAic->AIC_ICCR = 1 << AT91C_ID_TC0;

        pAic->AIC_EOICR = 0;
}
#endif




More information about the U-Boot mailing list