#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
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