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.

Coding > GBA -- Communication and Normal Mode

#164827 - Trecius - Mon Nov 24, 2008 5:22 am

Hello, All:

I've a question regarding GBA programming. I'm developing a small set of functions for sending information from one GBA to another GBA, but I'm having problems with the communication.

I can transmit information from the master to the slave, but information from the slave to the master is never received by the master. I am using normal node, and my rate is 256Kbit. I have posted my code below...


#define REG_IOCTRL *(volatile u16*)0x4000134
#define REG_SCCNT_L *(volatile u16*)0x4000128 // Serial Communication Channel Control Register
#define REG_SCDMAIN *(volatile u32*)0x4000120 // Serial Communication Data Register 0 and 1

#define ENABLE_MULTIPLAYER 0x7FFF
#define BIT_SO 0x0008
#define BIT_SI 0x0004

#define BIT_START 0x0080

void EnableCommunications()
{
REG_IOCTRL = REG_IOCTRL & ENABLE_MULTIPLAYER; // Bit 15 must be 0
#ifdef SLAVE
{
REG_SCCNT_L = 0x1008; // External Clock, SO = high during inactivity, 32-bit mode
}
#else // MASTER
{
REG_SCCNT_L = 0x1009; // Internal Clock @ 256 kHz, SO = high during inactivity, 32-bit mode
}

#endif
}

u32 Transmit(u32 data)
{
REG_SCDMAIN = data;

#ifdef SLAVE
{
REG_SCCNT_L = REG_SCCNT_L | BIT_START;
REG_SCCNT_L = REG_SCCNT_L & ~BIT_SO;

while (REG_SCCNT_L & BIT_START)
{
// Just wait
}
REG_SCCNT_L = REG_SCCNT_L | BIT_SO;
}
#else // MASTER
{
while (REG_SCCNT_L & BIT_SI)
{
// Just wait
}

REG_SCCNT_L = REG_SCCNT_L | BIT_START;
while (REG_SCCNT_L & BIT_START)
{
// Just wait
}
}
#endif

return REG_SCDMAIN;
}


Is my code flawed somewhere? When running only the slave and after initializing my communications, the slave's SO is never high; at least, as far as I can see.

Again, I ask if my code flawed? Do I need to do additional code initialization? Do I need to do additional hardware initialization anywhere? Thank you for your help.


Trecius

#164829 - eKid - Mon Nov 24, 2008 6:40 am

You need a special cable for normal mode. The normal multiplayer cable for GBA is meant for the multi-play mode. With the normal multiplayer cable (the one with the box in the middle) you can only do fast one-way communication in normal mode (ie master->slave1->slave2->slave3).

#164830 - Trecius - Mon Nov 24, 2008 6:47 am

Thank you. I have just figured that out too. I was looking at my cable, and I notice that my SI line is shorted to ground. As such, I can see why my master is constantly receiving 0. Blagh, this is just frustrating. It's time to rip apart the cable. I assume all I need to do is unground the cable and cross the SI and SO lines... leaving all other lines "straight-through?"


Trecius

#164832 - wintermute - Mon Nov 24, 2008 9:56 am

I beleive most of those multiplayer cables don't supply all the wires you need. I found that GBC 2 player cables work better.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog