I need help testing an ancient 2111 RAM for bad sectors.

I'm new to Arduino and need some help testing a 2111 RAM. I'm suspecting that it has bad sectors in it and figured that the best way to find out would be to write an Arduino program. This chip has 8 address lines, four input/output lines, a chip enable, a read write line, and an output enable. Here is the datasheet:

Unfortunately, I'm not familiar with the Arduino language. If anyone could help me get this scetch or main file together, I would appreciate it. Here's what I have so far in psuedo code:

/**Program to test 2111 ancient CRAM IC 256 x 4 Program steps through all addresses and writes 1 **then 0. After data is written, analog in ports read data from memory and print
**to terminal in nice columns. If error is 0 > .5v or if 1 < 4.0v flag data with highlight, bold, or **underline.
**/

Includes??

Activate Port Digital 0-7 for address stepping

Activate digital port 8-10 for read/write, Chip select, and output disable.

Activate analog in port 0-3 for inputs

// output enable

n = 256

// high test

enable write pin

for ( i = 0; i <= n; i++ )

address value = n

write = 0x0F to inputs

enable read pin

for ( i = 0; i <= n; i++ )

address value = n

// read outputs

float voltage = sensorValue * (5.0 / 1023.0);

printf( "output values for high write:" sensorvalue1, sensorvalue2, sensorvalue3, sensorvalue4 )

// low test

enable write pin

for ( i = 0; i <= n; i++ )

address value = n

write = 0x00 to inputs

enable read pin

for ( i = 0; i <= n; i++ )

address value = n

// read outputs

float voltage = sensorValue * (5.0 / 1023.0);

printf( "output values for low write:" sensorvalue1, sensorvalue2, sensorvalue3, sensorvalue4 )

return = 0;

2111.pdf (201 KB)

suspecting that it has bad sectors in it

A 256 x 4 bit SRAM device doesn't have "sectors"

Ha ha that completely slipped my mind. bad bits..

Can you explain the analogue port thing?
What's wrong with an ordinary I/O pin?

So you want to read every bit as an analog value in both it's high and low states? It wouldn't be a difficult sketch to write, but quite often I notice, if we put in the effort to come up with a solution for a newbie, by the time we post the solution, the newbie has gone, never to return again.

I want to make sure that there isn't a leaky or odd ball bit in there. If something is just under threshold, it could wreck havoc. This IC interfaces with TTL and CMOS. CMOS has different thresholds than TTL and I want to make sure that nothing is hanging around at a strange value. I attached a chart that explains things a little bit better.

KenF what do you want me to do? I didn't ask you to write it for me. I need help or, if you could point me in the right direction, that would be great. I'm pretty good with an atmega 328P-PU in ASM, and just learning C. I simply don't know the semantics of this language.

Which arduino do you have?

I have the Uno.

I'm not familiar with the Arduino language.

So what do you know? The Arduino language is just C, with some libraries.
This project would be somewhat annoying as a first C project...

Includes??

Normally not needed for arduino (some are added automatically.)

Activate Port Digital 0-7 for address stepping

0 and 1 are used for the serial comm to the pc; probably you want to not use that.

// output enable 

n = 256
// high test
enable write pin
for ( i = 0; i <= n; i++ )
 address value = n
 write = 0x0F to inputs
 enable read pin

Your pseudo-code is not quite compatible with the "switching time waveforms" in the datasheet. Those show that you should do something like:

// disable RAM output, READ/WRITE = READ.
// Write address
// Write chip enable
// for read: set data on Arduino as inputs, enable RAM output, read data on arduino.
// for write: set data on Arduino as outputs, write data from arduino, send pulse WRITE on READ/WRITE.

Note that the setting read/write or output-enable is the LAST part of the sequence.

To do this within the Arduino framework, you'll need to (annoyingly) write/read address and data one bit at a time, because the arduino libraries don't do groups of bits. You CAN read/write more than single bits by using "direct port io", depending on your level of understanding.

Don't use pins 0&1 because they are used for the serial communications.

Look at direct port addressing to transfer data to the address pins with only two writes.

Don't forget this is a16MHz system testing a 1MHz chip so don't go too fast.

I am not convinced however the results will be useful as it is just testing the output buffers of the chip which will be the same for any addressed memory location.

OK, I see what you mean about the read and write cycles. I might need to put some delays in there too. Can I change processor speed or is it fixed in Arduino?

The Arduino library doesn't read or write more than one bit at a time? I would think that I could write more than one bit at a time... I know that the ADC can only read one bit at a time.

I know this probably isn't the best project for me but hey, I've got to learn somehow. Do you have any suggestions for simpler projects I could start with?

Grumpy Mike, that's a good point.. Do you think I should hunt for new ones instead, assuming I can find them?

Here's something for you to play with. It's likely got quite a few bugs as I haven't any way of testing.

//PIN usage
const int addressPins[8]={4,5,6,7,8,9,10,11};
const int chipEnable = 2;
const int readWrite = 3;
const int outputDisable= 12;
const int dataPins[4]= {A0,A1,A2,A3};

int analogValue[4]; //used to store returned data

void setup()
{
Serial.begin(9600);
for(int n=0;n<8;n++)
 pinMode(addressPins[n],OUTPUT);
pinMode(chipEnable,OUTPUT);
pinMode(readWrite,OUTPUT);
pinMode(outputDisable,OUTPUT);

Serial.println("Ram test");
}

bool done = false;

void loop()
{
int address;
char buffer[30];
int n;

if(done) 
 return;

Serial.println("Writing 1111 to every address");
for( address=0; address<256; address++)
  writeValue(address,15);
  
Serial.println("Reading back");
for( address=0; address<256; address++)
  {
  sprintf(buffer,"Address %d ",address);
  Serial.print(buffer);
  readValue(address);
  for(int n=0; n<4; n++)
    {
     Serial.print(analogValue[n]);
     Serial.print("  ");
    }
  Serial.println(""); //newline
  }
  
Serial.println("Writing 0 to every address");
for( address=0; address<256; address++)
  writeValue( address, 0);
  
Serial.println("Reading back");
for( address=0; address<256; address++)
  {
  sprintf(buffer,"Address %d ",address);
  Serial.print(buffer);
  readValue(address);
  for(int n=0; n<4; n++)
    {
     Serial.print(analogValue[n]);
     Serial.print("  ");
    }
  Serial.println(""); //newline
  }

done=true;
};


void readValue(int address)
{
bool addressBit;
bool dataBit;
int n;

//prepare analog pins for analog reading
for(n=0;n<4;n++)
  {pinMode(dataPins[n],INPUT);
   digitalWrite(dataPins[n],LOW);
   delay(1);
   //make a reading and discard it
   analogRead(dataPins[n]);
  }


//disable output (should already be high)
digitalWrite(outputDisable,HIGH);

digitalWrite(readWrite, HIGH);

//write out address to address bus
for(int n=0;n<8;n++)  
  {addressBit = address & (1<<n);
   digitalWrite(addressPins[n],addressBit); 
  }

delay(1);

//send enable LOW
digitalWrite(chipEnable,LOW);
delay(1);

for(n=0;n<4;n++)
  analogValue[n]=analogRead(dataPins[n]);

//disable output
digitalWrite(outputDisable,HIGH);
digitalWrite(chipEnable,HIGH);
}



void writeValue(int address,byte value)
{
bool addressBit;
bool dataBit;
int n;

//write out address to address bus
for(int n=0;n<8;n++)  
  {addressBit = address & (1<<n);
   digitalWrite(addressPins[n],addressBit); 
  }

//disable output
digitalWrite(outputDisable,HIGH);

//put data on databus
for(int n=0;n<4;n++)  
  {pinMode(dataPins[n],OUTPUT);
   dataBit = value & (1<<n);
   digitalWrite(dataPins[n],dataBit); 
   digitalWrite(addressPins[n],addressBit); 
  }

digitalWrite(readWrite, LOW);
//may need a delay here

//send low pulse to chip enable to effect write
digitalWrite(chipEnable,LOW);
delay(1);
digitalWrite(chipEnable,HIGH);
}

tedjF:
Grumpy Mike, that's a good point.. Do you think I should hunt for new ones instead, assuming I can find them?

No, you can still do test read and writes to individual addresses but the buffers will either put out a 0 or a 1, so you don't need to bother with analogue.

Wow, thanks KenF. I'm eating dinner right now.. I'll test your code within the hour and let you know how it goes.

Well, I ran the code and it compiles without errors. Right now I'm studying up on nested arrays. Here is the output so far. Notice how it almost appears that the chip is turning off half way through the operation. My guess is that the chip enables or outputs are not in sync with the rest of the program. Reading back starts off low and then stabilizes.

Writing 1111 to every address
Reading back
Address 0 1001 976 958 979
Address 1 936 955 948 947
Address 2 918 941 942 932
Address 3 899 922 926 918
Address 4 884 910 912 901
Address 5 869 893 897 888
Address 6 856 879 885 875
Address 7 842 865 870 861
Address 8 822 839 847 841
Address 9 809 828 834 827


Address 244 29 59 64 50
Address 245 30 57 65 53
Address 246 33 60 69 55
Address 247 34 60 69 57
Address 248 29 49 63 53
Address 249 31 54 64 54
Address 250 34 59 68 55
Address 251 34 60 68 57
Address 252 36 65 72 58
Address 253 37 64 73 60
Address 254 40 66 75 61
Address 255 40 67 76 63

Writing 0 to every address
Reading back
Address 0 0 0 0 0
Address 1 0 0 0 0
Address 2 0 7 9 0
Address 3 0 12 16 2
Address 4 0 21 24 9
Address 5 0 22 29 15
Address 6 0 26 35 21
Address 7 2 28 37 25
Address 8 0 20 32 23
Address 9 4 25 34 25
Address 10 8 32 41 28
Address 11 10 34 43 31
Address 12 12 41 47 34
Address 13 15 42 49 37
Address 14 18 45 54 40
Address 15 20 46 55 43
Address 16 6 30 29 33
Address 17 10 35 38 31

Interesting. So it looks like we're getting close?

Try replacing the writeValue function with this.

void writeValue(int address,byte value)
{
bool addressBit;
bool dataBit;
int n;

//write out address to address bus
for(int n=0;n<8;n++)  
  {addressBit = address & (1<<n);
   digitalWrite(addressPins[n],addressBit); 
  }

//disable output
digitalWrite(outputDisable,HIGH);

//put data on databus
for(int n=0;n<4;n++)  
  {pinMode(dataPins[n],OUTPUT);
   dataBit = value & (1<<n);
   digitalWrite(dataPins[n],dataBit); 
   digitalWrite(addressPins[n],addressBit); 
  }

digitalWrite(chipEnable,LOW);
delay(1);
digitalWrite(readWrite, LOW);
//may need a delay here
delay(1);
digitalWrite(readWrite, HIGH);

delay(1);
digitalWrite(chipEnable,HIGH);
}

It's still got basically the same problem.

That's very odd. Is there a specific address where the readback becomes low?

Also I notice that the RAM chip has TWO Chip Enable pins (10 and 15) I assume you have tied these together?