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 > DMA problem

#37170 - demitri - Tue Mar 08, 2005 1:22 pm

Hey Everyone,
I'm having some issues with DMA. I'm trying to place some pointers in a specific place in memory. I can, however, create the pointers, but when I attempt to place an int into those memory addresses. I cannot find the value. here is my code. If you have any ideas. please let me know. thanks.


Code:

#define VariableData ((unsigned short*)0x8000000)
unsigned short* cdph_h= VariableData +4;
unsigned short* cdph_t = VariableData + 5;
unsigned short* cdph_s = VariableData + 6;
unsigned short* cdph_dt = VariableData + 7;
unsigned short* cdph_dh = VariableData + 8;


unsigned short* tdph_h = VariableData + 9;
unsigned short* tdph_t = VariableData + 10;
unsigned short* tdph_s = VariableData + 11;
unsigned short* tdph_dt = VariableData + 12;
unsigned short* tdph_dh = VariableData + 13;


unsigned short* pdph_h = VariableData + 14;
unsigned short* pdph_t = VariableData + 15;
unsigned short* pdph_s = VariableData + 16;
unsigned short* pdph_dt = VariableData + 17;
unsigned short* pdph_dh = VariableData + 18;
.
.
.

int main (void){

*cdph_h = 1;
*cdph_t = 2;


etc. thanks

#37184 - poslundc - Tue Mar 08, 2005 5:45 pm

The 0x08000000 region of memory points to ROM data, which is read-only.

Dan.

#37331 - tepples - Thu Mar 10, 2005 3:37 pm

Whether the data in the ROM section of the address map is read-only depends on your cart. For official Game Paks and EFA flash carts, it is read-only. For most other flash carts, it is read-only unless you execute a specific unlocking sequence, but that's a bit advanced for most of us, and given the quality reputation of Chinese no-name electronics, I wouldn't recommend repeated flash writes.

Use EWRAM instead, (EDIT) unless you need persistence. In that case, use SRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.


Last edited by tepples on Fri Mar 11, 2005 4:14 pm; edited 1 time in total

#37343 - poslundc - Thu Mar 10, 2005 5:55 pm

tepples wrote:
Whether the data in the ROM section of the address map is read-only depends on your cart.


So long as we're referring to it as the ROM section, though, I'm inclined to think of it primarily as read-only. ;)

Dan.

#37358 - demitri - Thu Mar 10, 2005 8:39 pm

Fair Enough.
Thanks.
So i''ve moved my thinking. Now i'm goin to write to EEPROM on the cart. so now i just have to write the functions to do so. Does anyone know of some working code i may have a look at. I have viewed the code in the post named "EEPROM Troubles". anyone know of any other code. I haven't tried that code yet. I'm in the process of doing so. Regardless, many sources are always a better learning tool... So if anyone knows of any please let me know. Thank again!
-Demitri

#37401 - FluBBa - Fri Mar 11, 2005 11:49 am

It's way easier to start out with just SRAM, starts at 0x0E00000 and ends at 0x0E007FFF.
_________________
I probably suck, my not is a programmer.

#37440 - demitri - Fri Mar 11, 2005 6:33 pm

I would use sram, but i can't. I'm actually going to write to EEPROM within a microchip PIC. thus, i need to write the EEPROM read/write protocol...
-demitri

thanks for the info though.

#37478 - ymalik - Fri Mar 11, 2005 10:21 pm

What is the minimum amount the DMA can copy and still be fast?

#37482 - poslundc - Fri Mar 11, 2005 11:04 pm

ymalik wrote:
What is the minimum amount the DMA can copy and still be fast?


It depends what memory regions you are copying to/from, but as a rule of thumb I usually don't bother to use DMA for copies under 32 bytes.

At that small an amount, of course, the speed advantage of one method or the other approaches insignificance, so I defer to software copying, which is generally less likely to interfere with other GBA systems and is easier to read and debug.

Dan.

#37492 - ymalik - Sat Mar 12, 2005 1:29 am

poslundc wrote:

It depends what memory regions you are copying to/from, but as a rule of thumb I usually don't bother to use DMA for copies under 32 bytes.


Much thanks.

I'm going to be copying either from ROM to VRAM, ROM to IRAM, IRAM to VRAM, ROM to WRAM, or WRAM to VRAM. Of course, I won't use all combinations: based on the size of the data from the ROM, I'm still deciding whether to use WRAM or IRAM for a temporary buffer.

#37537 - gb_feedback - Sat Mar 12, 2005 9:04 pm

Quote:
I would use sram, but i can't. I'm actually going to write to EEPROM within a microchip PIC. thus, i need to write the EEPROM read/write protocol...


That's a bit of a thread stopper. Do you mean that the EEPROM you want is in a PIC which is in a Cart? Or that you are going to use a PIC to write to the EEPROM on an official cart, or a commercial cart which uses EEPROM? This leaves me very confused.
_________________
http://www.bookreader.co.uk/

#37751 - demitri - Tue Mar 15, 2005 8:38 pm

yes... hahah. ok sorry.

The EEPROM is in a PIC which is in a Cartridge. its a home-made pcb board/cartridge, which contains the PIC. Internal to the PIC lives an EEPROM which i need to write to.
I have found the protocol i was looking for, and it doesn't freeze up the gameboy. well using an EZFA cartridge. the home-made cart is being built soon.

Thanks for everyone's input.
-demitri