namco
Member
I'm a little confused of which values to reset regarding the below code:
CODE
static const unsigned short MEMTIMEX0 = 0x3802;
static const unsigned short MEMTIMEX1 = 0x3804;
union memtimex0_t {
struct {
unsigned int tRCD : 4; // default = 2
unsigned int tRP : 4; // default = 15
unsigned int tRFC : 4; // default = 4
unsigned int tMRD : 4; // default = 4
} s;
unsigned short i;
};
union memtimex1_t {
struct {
unsigned int tWR : 4; // default = 2
unsigned int tRAS : 4; // default = 7
unsigned int tRC : 4; // default = 10
unsigned int LAT : 1; // default = 1; apparently readonly
unsigned int reserved : 2; // readonly
// Write: Set 1 to set new SDRAM mode parameter;
// Read: 0 = complete, 1 = busy
unsigned int ModeStatusSet : 1;
} s;
unsigned short i;
};
void ramhack()
{
memtimex0_t t0;
t0.i = memreg16(MEMTIMEX0);
t0.s.tRCD = 1;
t0.s.tRP = 1;
t0.s.tRFC = 0;
t0.s.tMRD = 0;
memreg16(MEMTIMEX0) = t0.i;
memtimex1_t t1;
t1.i = memreg16(MEMTIMEX1);
t1.s.tWR = 0;
t1.s.tRAS = 3;
t1.s.tRC = 5;
// The docs say to write 1 to set new mode
// parameter but seems to work without?
t1.s.ModeStatusSet = 1;
memreg16(MEMTIMEX1) = t1.i;
// Wait until mode is set. May not be necessary?
do {
t1.i = memreg16(MEMTIMEX1);
} while (t1.s.ModeStatusSet);
}
do I make another function like:
CODE
void unramhack()
{
memtimex0_t t0;
t0.i = memreg16(MEMTIMEX0);
t0.s.tRCD = 2; // default values
t0.s.tRP = 15; // default values
t0.s.tRFC = 4;
t0.s.tMRD = 4;
memreg16(MEMTIMEX0) = t0.i;
}
and run it before exit??
Thanks.
CODE
static const unsigned short MEMTIMEX0 = 0x3802;
static const unsigned short MEMTIMEX1 = 0x3804;
union memtimex0_t {
struct {
unsigned int tRCD : 4; // default = 2
unsigned int tRP : 4; // default = 15
unsigned int tRFC : 4; // default = 4
unsigned int tMRD : 4; // default = 4
} s;
unsigned short i;
};
union memtimex1_t {
struct {
unsigned int tWR : 4; // default = 2
unsigned int tRAS : 4; // default = 7
unsigned int tRC : 4; // default = 10
unsigned int LAT : 1; // default = 1; apparently readonly
unsigned int reserved : 2; // readonly
// Write: Set 1 to set new SDRAM mode parameter;
// Read: 0 = complete, 1 = busy
unsigned int ModeStatusSet : 1;
} s;
unsigned short i;
};
void ramhack()
{
memtimex0_t t0;
t0.i = memreg16(MEMTIMEX0);
t0.s.tRCD = 1;
t0.s.tRP = 1;
t0.s.tRFC = 0;
t0.s.tMRD = 0;
memreg16(MEMTIMEX0) = t0.i;
memtimex1_t t1;
t1.i = memreg16(MEMTIMEX1);
t1.s.tWR = 0;
t1.s.tRAS = 3;
t1.s.tRC = 5;
// The docs say to write 1 to set new mode
// parameter but seems to work without?
t1.s.ModeStatusSet = 1;
memreg16(MEMTIMEX1) = t1.i;
// Wait until mode is set. May not be necessary?
do {
t1.i = memreg16(MEMTIMEX1);
} while (t1.s.ModeStatusSet);
}
do I make another function like:
CODE
void unramhack()
{
memtimex0_t t0;
t0.i = memreg16(MEMTIMEX0);
t0.s.tRCD = 2; // default values
t0.s.tRP = 15; // default values
t0.s.tRFC = 4;
t0.s.tMRD = 4;
memreg16(MEMTIMEX0) = t0.i;
}
and run it before exit??
Thanks.