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.

Beginners > irq handler and mode 4 gfx

#25778 - quickcup - Sat Aug 28, 2004 8:05 am

I have been struggling with a problem for quite some time now and need some help.

The problem boils down to this:
- I am using mode 4 graphics.
- I have graphics drawing functions that work correctly at all times 'except ' when my interrupt handler is on the stack.

When my irq handler is on the stack and I try using my graphics functions I get indeterminate behaviour (lockups, distorted graphics, program resets, etc...)

Is this at all normal??
Thks

#25786 - poslundc - Sat Aug 28, 2004 4:20 pm

In most configurations, IRQs use a different stack than the main program that is only 160 bytes deep. Could this be the source of your problem?

Dan.

#25826 - quickcup - Sun Aug 29, 2004 2:53 am

I guess my next question then is how do I prevent the cpu from switching to the interrupt stack when an interrupt is triggered?

I have dug around a bit on how to do this but I'm still fuzzy.
Can it be done without using any assembly?

#25834 - poslundc - Sun Aug 29, 2004 4:47 am

In my version of Devkit Advance (which is pretty old by now, I imagine) you can specify different interrupt modes, and the Multiple Interrupt mode uses the main stack. So if you can configure your program to work with multiple interrupts you can access it that way with relaitve ease.

Otherwise, you cannot switch to the main stack without tinkering in assembly, as it requires accessing the GBA's system-control register to change the state.

But do you know if this is what's causing the problem? Better to figure out why you're getting the error rather than blindly stumbling around for a solution.

Dan.