# Programming a SRAM with Arduino

I'm currently trying to test some old NVSRAMs to make sure they work before I put them to use. Id like to test them independently and I'm thinking a arduino might do the trick. In theory, should a arduino mega be able to handle this?

PORTC = DQ0-DQ7
PORTA = A0-A7

            #define E           2
#define G           3
#define W           4

void fillOne();

void setup() {

Serial.begin(9600);
pinMode(E, OUTPUT);
pinMode(G, OUTPUT);
pinMode(W, OUTPUT);

DDRA = B11111111; // sets port a to output
DDRC = B11111111; // set port c to output

digitalWrite(E, HIGH);
digitalWrite(G, HIGH);
digitalWrite(W, HIGH);

}

void loop() {

fillOne();

}

//Test One

void fillOne()
{
int fail = 0;

PORTC = B11111111; // Sets Dataline to one

Serial.print("Test Start");
{
digitalWrite(W, LOW);
digitalWrite(E, LOW);
digitalWrite(W, HIGH);
}

//Read Back and check for One

// Sets Datalines to one

digitalWrite(W, HIGH);
digitalWrite(E, HIGH);

PORTC = 0x00;
DDRC = 0x00;

{

digitalWrite(G, LOW);
digitalWrite(E, LOW);

if(PORTC != B11111111)
fail ++;

digitalWrite(G, HIGH);

}

if(fail > 0)
{
Serial.print("FAIL");
Serial.print(fail);

while(1);
}

Serial.print("PASS");
while(1);

}


Update: I set it up to only use A0-A7 until I get it working, then will expand to other bits. I'm also only programming it with 1's so it's easier to debug for now. It's not quite working, I think it's the addressing.. I have Address set to a INT and it's going from 0 to 256.. If I send the int to a PORT, it should send out that number in binary, correct?

• If it's got enough I/O pins for all the address, data and control signals, yes of course. If it hasn't, you need to add more (perhaps using shift registers to store address bits) – Brian Drummond Sep 21 '16 at 16:03
• For what it's worth: if the modules are really old, the batteries are likely dead. – duskwuff -inactive- Sep 21 '16 at 16:20
• This is another question but I'm not that familiar with memory. What does the "valid" mean in the datasheet I linked. E.g, "Address valid to output valid". I'm working on the timing and will upload some code in a bit for clarity. – hybridchem Sep 21 '16 at 17:42
• 'valid' means just what it says - output data will be correct when the address has been stable for a certain period of time (much less time than the Arduino will take between setting up the address and reading the data). – Bruce Abbott Sep 21 '16 at 18:35
• Testing one bit at a time or in bytes will work, but either way you must test every bit for storing both '1' and '0'. So write alternating patterns to each address eg. 0x55 and 0xAA. – Bruce Abbott Sep 23 '16 at 20:31