This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SAM7SE512: __irq sends my interrupts into a loop

I have an interrupt routine to trigger when a PIO pin changes. It triggers when it should, but never seems to clear - it just keeps recurring thereafter.

void vbusDetIRQHandler(void) __irq
{
        ULONG isr, ivr;

        isr = *AT91C_PIOB_ISR;                                  // Clear all bits in the port B ISR.
        ivr = *AT91C_AIC_IVR;                                   // Clear current interrupt

        togglePin(AT91B_LED2);

        *AT91C_AIC_ICCR = 1 << AT91C_ID_PIOB;     // Clear PIOB interrupt.
        *AT91C_AIC_EOICR = 0;                                   // Signal end of interrupt
}


void initPortInterrupts(void)
{
        ULONG mask = 1 << AT91C_ID_PIOB;

        *AT91C_AIC_IDCR = mask;

        AT91C_AIC_SVR[AT91C_ID_PIOB] = (unsigned int)vbusDetIRQHandler;         // Store interrupt handler vector address.

        AT91C_AIC_SMR[AT91C_ID_PIOB] = AT91C_AIC_SRCTYPE_HIGH_LEVEL | 1;        // Source type and priority (7=high, 0=low)


        *AT91C_PIOB_IER = VBUS_DET;                                                                                     // Enable interrupt from the VBUS_DET pin.
        *AT91C_AIC_ICCR = mask;                                                                                         // Clear interrupt.
        *AT91C_AIC_IECR = mask;                                                                                         // Enable PIOB interrupts

}

I tried all sorts of things to fix it, until in desperation I commented out the __irq from the handler. Now it works perfectly.

Trouble is, I'm not happy with the fix because I don't understand WHY it works. Surely the __irq ought to be there - shouldn't it?

Any explanations?

0