New thread "Spurious Interrupts" - was - Re: [lpc2000] Disabling/enabling interrupt causing a data abort
2004-04-20 by microbit
Glad to be of help, Curt. I can't recall the exact circumstances of how this short few cclk cycles in the VIC (between telling it to disable INT xyz and the INT actually being masked off) works, but there are a few seasoned ARM buffs here that enlightened me on that. (see copy of Bill's post at end) The ultimate solution is to use a Global_IRQ_disable type func, then mask off the INT you want, and _then_ reenable Global_IRQ. This avoids what I guess you could call "spurious INts". I'm creating a new thread in case the gurus can fill us in on further nuts and bolts. I had weird things happening - with different optimisation levels, either a direct write to the TX/RX UART Int reg. would *seem* to make it behave, and then other times using a read-modify-write to mask would *seem* to make it behave. I noticed that if you even just take the Default_IRQ, do ONLY the prologue/epilogue, and return to the caller - even with Branch-Link - the Interrupt is still vectored after leaving Default_IRQ (I knew I wasn't loosing chars in the circular buffer for UART0, as default IRQ wasn't doing anything). But the advice of more experienced ARM users here was that this should *NOT* be done, the preferred method is the above ie. global disable IRQ, mask off INT, reenable IRQ. If you want to dig deeper, look for an earlier thread I called "UART TX FIFOs and INT problem". This was Bill Knight's advice at the conclusion (copy) : >>>>> Kris It's the old spurious interrupt problem. The fix is to disable global interrupts around the first read-modify-write instruction. Doing the direct write (U0IER = xxx) can still allow the problem to happen. What happens is the interrupt occurs and is recognized while the masking instruction is executing but before it has completed. Then when the instruction does complete, the interrupt can't find the vector so uses the default. So to fix: Disable global interrupts mask interrupt Enable global interrupts do your stuff unmask interrupt NOTE: I don't think this last modification of the mask register needs protection. Someone correct me if I am wrong. Regards -Bill Knight R O SoftWare >>>>>>>>>>> Cheers, Kris De Vos
Show quoted textHide quoted text
> Kris, > > I added an assembler harness to accept the default irq, loaded up > VICDefVectAddr with its address, and let it fly. The default handler is > being called periodically (it just prints a diagnostic and returns) so > it appears to be working- I can't give a definitive answer until it runs > for a couple of hours, but so far so good. Thanks so much for your > insight. > > Curt