Reading and Writing to a Pipeline SRAM

Hey guys, So I'm trying to Write and Read to a Pipeline SRAM

data-sheet here

After implementing the code below I thought I had figured out the process to get just one write and one read, however after unplugging my I/o pins I realized my serial monitor was still spewing out the "correct output" so now i'm very confused. Im guessing that I'm really just reading my original input for the write command and the SRAM is actually having no effect even though the device is on and fully wired. Also forgive me if I'm missing a basic concept here I'm a beginner.

int clk = 9;
int CE1 = A1;
int CE0 = A0;
int BE = 2;
int rwPin = 4;
int odPin = 3;
int dataPins[] = {A2,A3,A4,A5};
int addressPins[] = {13, 12, 11, 10, 8, 7, 6, 5};


void setup()
{
 
tone(clk,1000);
  Serial.begin(9600);
  
  for (int i = 0; i < 8; i++)
  {
    pinMode(addressPins[i], OUTPUT);
  }
  pinMode(rwPin, OUTPUT);
  pinMode(odPin, OUTPUT);
  pinMode(CE0, OUTPUT);
  pinMode(CE1, OUTPUT);
  pinMode(BE, OUTPUT);
  
    /*Set Data Pin Modes to Output*/
  for (int i = 0; i < 4; i++)
  {
    pinMode(dataPins[i], OUTPUT);
  }

}


void writeData()
{ 

    for (int i = 0; i < 4; i++)
  {
    pinMode(dataPins[i], OUTPUT);
  }
  
  for (int i = 0; i < 8; i++)
  {
   
      digitalWrite(addressPins[i], HIGH);
  }

  
  digitalWrite(rwPin, LOW);
  digitalWrite(CE0, LOW);
  digitalWrite(CE1, HIGH);
  digitalWrite(BE, LOW);
  
  delay(1);

  digitalWrite(dataPins[0], LOW);
  digitalWrite(dataPins[1], LOW);
  digitalWrite(dataPins[2], LOW);
  digitalWrite(dataPins[3], HIGH);

 delay(1);
 

}

 void readData()
{

  
for (int i =0;i<4;i++)
  {
    pinMode(dataPins[i], INPUT);
  }


  for (int i = 0; i < 8; i++)
  {
   
      digitalWrite(addressPins[i], HIGH);
  }
 
delay(1);

  
  /*Set Read Mode*/
  digitalWrite(CE0, LOW);
  digitalWrite(CE1, HIGH);
  digitalWrite(odPin, LOW);
  digitalWrite(rwPin, HIGH);
  digitalWrite(BE, LOW);


delay(.5);

for (int i=0;i<4;i++)
  {
      if (digitalRead(dataPins[i]) == 0)
      {
Serial.print("0");
      }
      else 
      {
Serial.print("1"); 
      }
      }

Serial.print("\n");



/* disable output */
  digitalWrite(CE0, HIGH);
  digitalWrite(CE1, LOW);
  digitalWrite(BE, HIGH);
      
  }



  

void loop() {
  writeData();
  delay(1000);
  readData();
  delay(500);

}

Please post your schematic.

You should turn off the chip's output drivers before you start driving them as inputs.
digitalWrite(odPin, HIGH);

The delay() function only takes integers. If you want 0.5 milliseconds, use delayMicroseconds(500);

You should get the same output with one line:
Serial.print(digitalRead(dataPins[i]));

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.