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.

Hardware > How does DMA controller really work?

#493 - notron - Wed Jan 08, 2003 3:49 am

Newbie here with another question. I have searched everywhere for the answer but haven't found it.

When using DMA mode ( channel 3, wait-for-vertical-sync, WITHOUT interrupts enabled), how does the GBA handle it. E.G. when I set the control register, does it suspend further code execution until the DMA is complete, or does it continue own executing code? If it is the later case, then how does the DMA controller interrupt code execution in order to take over the bus and complete the DMA operation?

I am testing this on the Boycott Advance and am getting some interesting effects ( very delayed completion of the DMA operation) and I am wondering if this is an artifact of the emulator or if this is really the way the GBA works?

If anyone knows where there is a detailed manual of the GBA, I would love to get my hands on it. I have the GBATEK by Martin Korth but it doesn't go into this much detail on HW operation.
_________________
MysticX is The Defender

#520 - ampz - Wed Jan 08, 2003 10:30 am

DMA transfers halts the execution until completed.

#528 - imikeyi - Wed Jan 08, 2003 1:55 pm

The "Cowbite Virtual Hardware Specifications" seems to be the most detailed reference for the GBA.

#536 - Splam - Wed Jan 08, 2003 3:04 pm

The dma won't start until it hits a vsync (wait-for-vertical-sync set), then the dma starts, the processor will stop executing instructions until the dma transfer is complete. Also remember the vblank period starts at line 160 not line 0 (which is a good thing because you've got all that time to process the dma b4 the screen is redrawn) but maybe you're expecting it to begin at 0 or even as soon as you trigger it?

#539 - Touchstone - Wed Jan 08, 2003 3:18 pm

Are you sure that DMA transfers aren't executed until the vblank interrupt?
_________________
You can't beat our meat

#540 - Splam - Wed Jan 08, 2003 4:23 pm

Depends if you tell them to be or not. You can choose to start now, next vblank, next hblank or another one, damn forgot what that one is, something to do with the sound dma i think hehe but notron said he'd set it to the vblank one.

#549 - notron - Wed Jan 08, 2003 6:28 pm

Well, from all the comments I have come to the conclusion that what I am seeing is an artifact of the Boycott Advance emulator. I am telling it to wait for the next VBLANK before starting the DMA, but I do NOT have interrupts enabled for the DMA. In this case I expected the code execution to be halted at the point of setting the DMA control register and then waiting until VSync, then completing the DMA, then resuming execution of the code. In actuality, it appears in my prorgram that the code continued to execute while the DMA controller was waiting for the next VSYNC and then it would halt execution of the code, complete the DMA and then resume execution of the code. I suspect that the emulator is using a separate thread to emulate the DMA controller and that thread is running at the same W9x priority as the main code thread, thus it is having to wait for its w9x time slice before it can start checking and waiting for the Vsync. Since the main code thread was not immediately suspended when it set the DMA control register, it continued to execute until the end of its time-slice.

Of course, I can't be sure without looking at the code for the emulator, but from the appearance of my display, this appears to be what happened.

Thanks to everyone who contributed input.
_________________
MysticX is The Defender

#635 - Splam - Thu Jan 09, 2003 7:42 am

I'd suggest using VBOY instead, boycott is nowhere near as accurate (even with the new release). Also you seem to have got the wrong idea about DMA interrupts, they're triggered when a dma is finished, nothing to do with when they start, stupid most of the time I know because the processor is stopped anyway but it can be used in some cases (audio processing).

The settings you've got will set the dma into "wait for vsync" the processor will continue doing its thing, vsync happens, dma starts, dma finishes, precessor restarts.. If you had dma interrupt request turned ON it would TRIGGER an interrupt AFTER the dma completes, nothing to do with when dma starts. :)

#668 - notron - Thu Jan 09, 2003 4:34 pm

Splam,

Thanks for the update. The issue was whether or not the processor kept on running after issuing the DMA "wait for sync". You answered that and now I know it keeps running until the vsync event halts it. I didn't do a good job of explaining the interrupts thing, but I did know that the interrupt, if enabled, would be on completion of the DMA. I was just noting that I did not have it enabled.

Thanks also for the tip on VBOY. I will check it out immediately. I was just using Boycott Advance based on recommendation from someone else.

Thanks again.
_________________
MysticX is The Defender

#670 - Splam - Thu Jan 09, 2003 4:41 pm

No problem, forums aren't the best place to work out problems due to the time lag between asking, waiting for a reply, realising the reply isn't what you wanted etc :)