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 > DS Card slot writing

#91317 - TheRain - Thu Jul 06, 2006 8:27 am

I'm trying to write data to the DS card slot's I/O 0 - 7 pins... i won't be surprised if no one has an answer for this, but I thought I'd try anyway.

I have the folowing code:

Code:

void paralellWrite(char b)
{
CARD_EEPDATA=0x00;
CARD_CR1 = /*E*/0x8000 | /*SEL*/0x2000 | /*MODE*/0x40 | 7;   // frequency divided 7
EepromWaitBusy(); // waits for CARD_CR1 busy flag to be false
CARD_EEPDATA=b;
CARD_CR1 = 0x40;
}


in my main loop I have this code for calling the function upon button press:


Code:

if(held & KEY_X)
{
iprintf("BUtttON X");
paralellWrite('U');
}



I can see the text for Button X on the screen when I press it, but I see no data on my oscope.. levels sit at steady 3.27 V I'm starting to think that maybe even though I have Flashme on my DS, I need to do some hardware handshaking with the card slot or something to convince the DS that it is ok to now write data... does anyone know if this is true or not?

I have no IC's or CPLD's or chips of any kind at the card slot as of now, I am just analyzing the pins themselves straight from the card slot. I have been trying to read through and comprehend the VHDL code for the original Passme, but I haven't figured out from that if I need to have a chip at the card slot to send response to something in order to start I/O.

any ideas?? or does anyone know of some documentation for the card.h portion of libnds?

#91327 - chishm - Thu Jul 06, 2006 10:58 am

If you are running this on the ARM9 CPU, make sure to give it control of the DS card slot.
Code:
WAIT_CR &= ~ARM9_OWNS_CARD;

_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#91360 - TheRain - Thu Jul 06, 2006 6:27 pm

you're awesome!

well my paralell write code still doesn't work I don't think... but natrium42's serial code is working so I know I've got output. thanks so much!

What does that do exactly anyway? when I started trying to learn to nds programming I used some tutorial that taught me that I needed to have basically two executables, one for the arm7 and one for the arm9 in order to have access to all of the functions.... but then when I went through the example code that comes with libnds I saw that most were done with one arm9 main, in the code at least... I'm sure it's still two once it's compiled. But I'm kind of curious as to what was changed in the arm compiler to allow this.

#91477 - cory1492 - Fri Jul 07, 2006 12:27 pm

You have to tell the DS which processor has access to certain things, or else conflicts can happen (like both processors trying to access the DS card at the same time).

NDStool will provide a "generic" A7 code if you dont have it specified when building the ROM, IIRC it would be the same as the A7+A9 template code though the source to ndstool (cvs) should have it there as well. AFAIK retail games actually have a "generic" A7 code that isnt provided by game developers.