|
Hi all,
I'm facing with spureos interrupt in some occasions, I modified the default spurious interrupt handler in my application with the following code:
void defaultSpuriousHandler( void ) {
spurious = AT91C_BASE_AIC->AIC_SPU; *AT91C_AIC_EOICR = *AT91C_AIC_EOICR;
return;
}
Inmediately after the code is finished, I check if a spureos interrupt has happened, if so, I enable the CAN interrupt so the original interruption is handled properly, as I can't simply discard that interruption. But I'm not dure if I'm losing it, or whether I should make any other action.
The following code shows you how I manage when I try to disable the interrupt, and how to detect if a spurious interrupt happended:
//Wait for pending register to be clear, so we decrease the number of spurious do { }while (AT91C_BASE_AIC->AIC_IPR != 0);
//Once we know that there is no interrupt pending, we try to disable the CAN interrrupt //And start the critical section //only disable the CAN interrupt because I know that there is no other interrupt happening AT91C_BASE_AIC->AIC_IDCR = 1 << AT91C_ID_CAN;
//This is a little weird, but I checked that this value tells me that the spurious exception happened if (spurious != 0 ) { //If a spurious interrupt happened I enable the interrupt so the original interrupt //will be handled by the CAN handler so I'm not losing CAN messages AT91C_BASE_AIC->AIC_IECR = 1 << AT91C_ID_CAN; spurious = 0; return -1; // We finished the method and try later to run the critical section } Thank you very much for your help.
Javier Barbarán.
|