serial eeprom

hey

I have this microchip 93LC56A eeprom.I want to read and write this eeprom .I have tried bunch of stuff.I have read
its pdf all it says is . The 93LC56A powers up in the ERASE/WRITE
Disable (EWDS) state. All programming modes must be preceded by an ERASE/WRITE Enable instruction.
i have send (EWEN) instruction and then write instruction and then the data but it wont work at all.
i know how to work with I2C eeprom but its a different story,
so please can anyone help me out here.

thanks

The interface looks sort of like SPI but the commands are all 12 bits or 12 bits followed by 8 bits of data (in or out). Since 12 and 20 not in multiples of 8 you probably can't use the SPI hardware. You might want to implement something like shiftOut() that will take 12 bits from an int and clock them out. Then you can use shiftOut() or shiftIn() to transfer the 8-bit data value. Another useful function would be one to wait for Ready: set CS high an wait for the chip DO to go HIGH.

http://ww1.microchip.com/downloads/en/DeviceDoc/21794G.pdf.

I voted. Hope that helps.

can u please tell me how to send instruction i think im not getting it.

you need to define the CLK DI and DO lines inyour arduino sketch and creat functions to control them. NO time to dive into the right code but just to give you an idea

This is not working code but it should give you an idea how to address this project. I did not follow the logic in the datasheet par 2.7 & 2.8) , but it should be sufficient to get you started.

#define CS 6
#define CLK 7
#define DI  8
#define DO 9

void setup()
{
  Serial.begin(115200); // for io with PC
  Serial.println("eeprom test 0.001");

  pinMode(CS, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DO, OUTPUT);  // to be connected to the DI of the chip
  pinMode(DI, INPUT);   // to be connected to the DO of the chip. (think perspective ;)
  
}

void loop()
{
  for (int i=0; i< 256; i++)
  {
    SE_write(i, i);   // just a test pattern
  }

  for (int i=0; i< 256; i++)
  {
    int x = SE_read(i);   // read it back
    Serial.println(x);     // and print it to check.
  }

  while (1);  // stop the loop.
}

// EEPROM FUNCTIONS
// READ see par 2.7 
int SE_read(int address)
{
  int rv = 0;
  digitalWrite(CS, HIGH);  // chip select

  // 110 pre signal
  digitalWrite(DO, HIGH);
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);

  digitalWrite(DO, HIGH);
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);

  digitalWrite(DO, LOW);
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);

  // clock in the address
  for (int p =0; p< 8; p++)
  {
    digitalWrite(DO, bitRead(address, 7-p));  // or (address, p)
    digitalWrite(CLK, HIGH);
    digitalWrite(CLK, LOW);
  }
  // read the value
  for (int p =0; p< 8; p++)
  {
    digitalWrite(CLK, HIGH);
    rv <<= 1;
    rv += digitalRead(DI);
    digitalWrite(CLK, LOW);
  }
  digitalWrite(CS, LOW);  // chip select
  return rv;
}

int SE_write(int address, int value)
{
   int rv = 0;
  digitalWrite(CS, HIGH);  // chip select

  // 101 pre signal
  digitalWrite(DO, HIGH);
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);

  digitalWrite(DO, LOW);
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);

  digitalWrite(DO, HIGH);
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);

  // clock in the address
  for (int p =0; p< 8; p++)
  {
    digitalWrite(DO, bitRead(address, 7-p));  // or (address, p)
    digitalWrite(CLK, HIGH);
    digitalWrite(CLK, LOW);
  }
  // write the value
  for (int p =0; p< 8; p++)
  {
    digitalWrite(CLK, HIGH);
    digitalWrite(DO, bitRead(value, 7-p));  // or (address, p)
    digitalWrite(CLK, LOW);
  }
  digitalWrite(CS, LOW);  // chip select
  return rv;
}

now its your turn :wink:

G'day raees

i have already had experience with using a similar chip, the at93c56. This one includes an active org pin so you can set it to either 8 or 16 bit organisation. I think yours is manufactured as an 8 bit organisation.

I have written a library to interface with these chips, you can have a look at it here http://arduino.cc/forum/index.php/topic,89658.0.html Anything discussed below will refer to the library, so i suggest you read the header comments first which will help you make sense of what i say below.

the library utilises five pins one of which is for the org pin. since yours is set i think you will be able to set pin variable to an arbitrary pin, it will set it to either a high or low state but you will be able to use it afterwards i think. But you still must be give a variable for the organisation.

It will handle all the opp codes and timing. since it can handle both 8 and sixteen bit organisation some commands are divided into either byte or word commands.The comments in the library should explain that better. It is messy code but it was my first real foray into writing a library.

hey thanks for this lib works fine.if u include some examples it wont take that much time to understand.

have a good day.