Hey guys, So I'm trying to Write and Read to a Pipeline SRAM
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);
}