Testing old ram chips

I'm testing some nec d43256c ram chips, but all I can ever read back is 1's from the data lines. I'm not sure what could be wrong with my code .... I've added some additional delays, etc to see if that helped, but nothing changes.

I'm addressing the 14 address lines through 2 shift registers. I tested that circuit, and it appears to be working correctly.

ram datasheet: UPD43256C-12L Datasheet pdf - 32768 x 8-bit static MIX-MOS RAM, 120ns, low power - NEC


// quick arduino sketch to test d43256c ram w/ shift registers

#define   SERIAL 2
#define   LATCH 3
#define   CLOCK 4

#define   DATA0 5
#define   DATA1 6
#define   DATA2 7
#define   DATA3 8
#define   DATA4 9
#define   DATA5 10
#define   DATA6 16
#define   DATA7 14

#define   WE 15
#define   OE 18


void setup() 
{
  pinMode(SERIAL, OUTPUT);     
  pinMode(LATCH, OUTPUT);
  pinMode(CLOCK, OUTPUT);  

  pinMode(DATA0, OUTPUT); 
  pinMode(DATA1, OUTPUT);  
  pinMode(DATA2, OUTPUT);  
  pinMode(DATA3, OUTPUT);  
  pinMode(DATA4, OUTPUT);  
  pinMode(DATA5, OUTPUT);  
  pinMode(DATA6, OUTPUT);  
  pinMode(DATA7, OUTPUT);

  pinMode(WE, OUTPUT);  
  pinMode(OE, OUTPUT);  
  
  
  Serial.begin(9600);
}

void sendData(unsigned data)
{
  pinMode(DATA0, OUTPUT); 
  pinMode(DATA1, OUTPUT); 
  pinMode(DATA2, OUTPUT);  
  pinMode(DATA3, OUTPUT);  
  pinMode(DATA4, OUTPUT);  
  pinMode(DATA5, OUTPUT);  
  pinMode(DATA6, OUTPUT);  
  pinMode(DATA7, OUTPUT);  

  digitalWrite(OE, HIGH);
  
  // 14 addr lines
  for(unsigned addr = 0; addr <= 0b11111111111111; addr++)
  {
    
    //digitalWrite(WE, LOW);-- ORIG
    digitalWrite(WE, HIGH);
    
    // set address
    digitalWrite(LATCH, LOW);
    //shiftOut(SERIAL, CLOCK, LSBFIRST, addr);
    //shiftOut(SERIAL, CLOCK, LSBFIRST, addr>>8);

    shiftOut(SERIAL, CLOCK, MSBFIRST, addr>>8);
    shiftOut(SERIAL, CLOCK, MSBFIRST, addr);
    
    digitalWrite(LATCH, HIGH);

    delayMicroseconds(120);

    // set data.  Sadly the pins arent all on a single port.
    digitalWrite(DATA0, data | (1));
    digitalWrite(DATA1, data | (1<<1));
    digitalWrite(DATA2, data | (1<<2));
    digitalWrite(DATA3, data | (1<<3));
    digitalWrite(DATA4, data | (1<<4));
    digitalWrite(DATA5, data | (1<<5));
    digitalWrite(DATA6, data | (1<<6));
    digitalWrite(DATA7, data | (1<<7));

    // end the write cycle 
    //digitalWrite(WE, HIGH);
    digitalWrite(WE, LOW);
	
	  // I think this is the right delay time...
    delayMicroseconds(120);
  }

}


void verifyData(unsigned data)
{
  pinMode(DATA0, INPUT); 
  pinMode(DATA1, INPUT); 
  pinMode(DATA2, INPUT);  
  pinMode(DATA3, INPUT);  
  pinMode(DATA4, INPUT);  
  pinMode(DATA5, INPUT);  
  pinMode(DATA6, INPUT);  
  pinMode(DATA7, INPUT);  

  digitalWrite(OE, LOW);
  digitalWrite(WE, HIGH);
  
  // 14 addr lines
  for(unsigned addr = 0; addr <= 0b11111111111111; addr++)
  {

    
    // set address
    digitalWrite(LATCH, LOW);
    //shiftOut(SERIAL, CLOCK, LSBFIRST, addr);
    //shiftOut(SERIAL, CLOCK, LSBFIRST, addr>>8);
    shiftOut(SERIAL, CLOCK, MSBFIRST, addr>>8);
    shiftOut(SERIAL, CLOCK, MSBFIRST, addr);
    digitalWrite(LATCH, HIGH);

    // address access time
    delayMicroseconds(120);

    unsigned currentByte = digitalRead(DATA0)      | (digitalRead(DATA1)<<1) |
                           (digitalRead(DATA2)<<2) | (digitalRead(DATA3)<<3) |
                           (digitalRead(DATA4)<<4) | (digitalRead(DATA5)<<5) |
                           (digitalRead(DATA6)<<6) | (digitalRead(DATA7)<<7);

    if (currentByte != data)
    {
      Serial.print("Error found at addr: ");
      Serial.print(addr, BIN);

      Serial.print("  Read: ");
      Serial.print(currentByte, BIN);

      Serial.print("  Expected: ");
      Serial.println(data, BIN);
    }

  }
  
}



void loop() 
{
  while (Serial.available() <= 0)
  {
    Serial.println("enter any text to start");
    delay(50);
  }
  Serial.write("starting");

  // write 4 different repeating values and read them back
  

  Serial.println("Testing 0x00");
  unsigned data = 0;
  sendData(data);
  verifyData(data);
  
  data = 0xFF;
  Serial.println("Testing 0xFF");
  sendData(data);
  verifyData(data);

  Serial.println("Testing 0b10101010");
  data = 0b10101010;
  sendData(data);
  verifyData(data);

  Serial.println("Testing 0b01010101");
  data = 0b01010101;
  sendData(data);
  verifyData(data);



  Serial.println("Finished");
}

A schematic (not fritzing!) of your project would be quite useful.

2 Likes
    // set data.  Sadly the pins arent all on a single port.
    digitalWrite(DATA0, data | (1));
    digitalWrite(DATA1, data | (1<<1));
    digitalWrite(DATA2, data | (1<<2));
    digitalWrite(DATA3, data | (1<<3));
    digitalWrite(DATA4, data | (1<<4));
    digitalWrite(DATA5, data | (1<<5));
    digitalWrite(DATA6, data | (1<<6));
    digitalWrite(DATA7, data | (1<<7));

This will always be setting the outputs to HIGH, did you mean to use AND instead of OR?

2 Likes

Do you have the OE and WE outputs going through inverters? CS, OE, and WE are all active LOW, and the write data needs to be stable at the rising edge of WE (or CS) that terminates the write cycle.

:man_facepalming:
Yes, I was staring at that not realizing what I was doing .... thanks.

I don't have OE or WE going through inverters.
To make sure I'm writing correctly .. the process should be like this? WE high -> set addr -> set data -> WE low -> delay -> repeat
Is that right, or am I backwards?

Do you have CS wired LOW permanently? If so, then the write process appears to go like this:

set Address
set WE LOW
set Data
delay
(minimum 100nS from stable address)
(minimum 60nS from stable data)
(minimum 90nS from WE LOW)
set WE HIGH
delay may be needed before repeating, write cycle time is 150nS minimum

Either CS or WE (or both) must be high when changing Address
OE must be HIGH to prevent data output from the memory chip (should only be LOW during a read operation)
WE remains HIGH at all times outside of the write operation.
The data lines from the Arduino must be put back into INPUT mode after finishing the write operations. Safest to do this at the end of the function that performs the write operation.

Yeah, CS is wired low. I'll play with it again soon. Thank you for your help! Just changing it to bitwise AND fixed it for the most part. I do think I may need to change a few delays to get a proper test done though. It fails when writing all 1's

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