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(){
}