gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Interrupts Interrupting Interrupts... que'd or ignored?

#145259 - Natso - Tue Nov 13, 2007 6:45 am

Ok, speaking strictly for the ARM7 here...

Situation:
Audio Interrupt triggers, and is in the proccess of handling it's data when all of a sudden...
Keypad Interrupt!


What my main question is how exactly will this resolve?
I hear that interrupts can't interrupt each other, so...

Will the interrupt simply never happen?
Will the interrupt happen after the resolution of the audio interrupt?
And... is the keypad interrupt continuous? (Like, until you release that key? or is it only triggered on key-press)
_________________
I'm a bomb technitian. If you see me running, try to keep up ;)

#145398 - gladius - Wed Nov 14, 2007 10:05 pm

Interrupts can be re-entrant, so it depends on the current default behavior of libnds what will happen. Assuming that re-entrant interrupts are disabled, the keypad interrupt will happen after the audio interrupt has completed processing.

Interrupts are not continuous. Basically, after every instruction the processor checks if any bits are set in REG_IF and if interrupts are enabled. If there is one set, it disables interrupts, switches to irq mode and jumps to the irq handler. This is why you have to set the bit in REG_IF in your interrupt handler. If you don't, it will just fire the interrupt immediately again after interrupts are enabled.

In the keypad case, I don't remember when the REG_IF bit is set, but as long as the bit isn't cleared, the interrupt will be waiting around to happen as soon as interrupts are enabled.