Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm Tom. I'm pretty new to electronics and programming but I've been getting better. So, recently I bought a 93lC46B EEPROM from Element 14 (It was $0.28! Why not!). I've been doing some research and reading the datasheet VERY carefully. But I still can't get the EEPROM to work right. I'm using an Arduino Uno to program the chip by using the Bit-Banging method. So what I've understood is that I need to cycle the clock, then pull the CS (Chip select) to high and then cycle the clock after each bit like this:

digitalWrite(CLK, LOW);
digitalWrite(DATAIN, VALUE);
digitalWrite(CLK, High);

But so far, that method hasn't been working right. I can't seem to read or write to the device properly. I'm using this set of bits to write 1 and 2 to the first address of the ROM: 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0.

Here's my code so far (Sorry in advance on how bad it is):

#define DATAOUT 11//Comes from DO on chip MISO
#define DATAIN 13 //Goes to DI on chip    MOSI
#define CLK 10
#define CS 9

int data[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int inst1[] = {1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,1,1,0,0,1,0};
int inst2[] = {1,1,0,0,0,0,0,0,0};

void setup(){
  Serial.begin(9600); //Start serial coms

  pinMode(CS, OUTPUT);
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(CLK, OUTPUT);
  digitalWrite(CS, LOW);

  //Write 12 to address 1
  digitalWrite(CS, HIGH); //Enable device
  //Write to memory
  for(int i=0;i<25;i++){
    Write(inst1[i]);
  }
  digitalWrite(CS, LOW); //Disable device
  delay(250); //TCSL Delay
  Serial.print("Memory sucessfully written\n");

  //Read memory
  digitalWrite(CS,HIGH); //Enable device
  for(int i=0;i<9;i++){
    Write(inst2[i]);
  }
  Serial.print("Read instruction written\n");
  for(int i=0;i<16;i++){
    saveBit(i);
  }
  for(int i=0;i<16;i++){
    Serial.print(data[i]+"\n");
  }
  digitalWrite(CS,LOW);
  delay(250);
  Serial.print("Read successful!\n");
}

void Write(int Bit){
  digitalWrite(CLK, LOW);
  if(Bit==0){
    digitalWrite(DATAIN, LOW);
  }
  if(Bit==1){
    digitalWrite(DATAIN, HIGH);
  }
  digitalWrite(CLK, HIGH);
  delay(1);
}

void saveBit(int outbit){
  digitalWrite(CLK, LOW);
  if(digitalRead(DATAOUT) == HIGH){
    data[outbit] = 1;
  }
  if(digitalRead(DATAOUT) == LOW){
    data[outbit] = 0;
  }
  digitalWrite(CLK, HIGH);
  delay(1);
}

void loop(){

}
share|improve this question

migrated from electronics.stackexchange.com Jan 19 '15 at 20:32

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

    
Where have you connected your 93LC46's ORG pin? – brhans Jan 19 '15 at 20:16
    
@brhans This chip does not have an ORG pin. Read the data sheet before asking please. – Maxthon Chan Jan 19 '15 at 20:23
    
Try access it with hardware SPI first. Mybe that can help. – Maxthon Chan Jan 19 '15 at 20:24
    
I wanted the experience of running it with big-banging but I could try the SPI. I've found lots of posts for SPI. – user3726825 Jan 19 '15 at 20:26
    
Yet another improper migration from EESE. The problem here is not with Arduino, but rather with lacking understanding of the peripheral's interface. Send it back! – Chris Stratton Jan 19 '15 at 21:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.