At 10:02 PM 12/9/05 +0000, Ken Wada wrote: >Asynchronously turning off and on interrupts in the main body of your >code is problematic. Instead of tempting fate; I decided to play the >overly-cautious role. It is the following excerpt from the Philips >User Manual that gave me pause: > >"Although the example shows both IRQ and FIQ interrupts being >disabled, similar behavior occurs when only one of the two >interrupt types is being disabled. The fact that the core processes >the IRQ after completion of the MSR instruction which disables >IRQs does not normally cause a problem, since an interrupt arriving >just one cycle earlier would be expected to be taken. When >the interrupt routine returns with an instruction like: >SUBS pc, lr, #4 >the SPSR_IRQ is restored to the CPSR. The CPSR will now have the I bit >and F bit set, and therefore execution will continue >with all interrupts disabled." Which, of course, is what it should do since that is what was being asked of it. IE the sequence disable interrupts critical code restore interrupts will always result in the interrupts being re-enabled at the end. The only problems that occur are if the code following the interrupt disable sequence is using tricky flag manipulation to determine if it is in an interrupt or not, or if you are using both IRQs and FIQs. The later case strikes me as far more likely and there are several simple work-arounds for that. the simplest being to disable the IRQ and FIQ in sequence rather than both at once where you need critical region protection. However if you either don't use the FIQ or don't care if it is occasionally disabled during an IRQ the status register manipulation should be safe. I don't see any reason for the interrupt detection code to be much more than a parlour trick, although I could be convinced otherwise. Robert " 'Freedom' has no meaning of itself. There are always restrictions, be they legal, genetic, or physical. If you don't believe me, try to chew a radio signal. " -- Kelvin Throop, III http://www.aeolusdevelopment.com/
Message
[lpc2000] Re: Problem with watchdog
2005-12-10 by Robert Adsett
Attachments
- No local attachments were found for this message.