Alright, so I have an Atmel 93C66, http://www.atmel.com/Images/doc0172Z.pdf Datasheet and I'm wanting to read whatever is in it.
I copied the following code from this thread http://forum.arduino.cc/index.php?topic=96411.0 and made some changes to it, mainly I deleted the part where it writes:
//difining pins for eeprom
int CLOCK =4;
int DATA_OUT =3;
int DATA_IN = 2;
int CHIP_SEL =5;
int low =0; //low address
byte READ = 0b1100; //read instruction
void setup(){
pinMode(CLOCK ,OUTPUT);
pinMode(DATA_OUT ,OUTPUT);
pinMode(DATA_IN ,INPUT);
pinMode(CHIP_SEL ,OUTPUT);
digitalWrite(CHIP_SEL ,LOW);
digitalWrite(CLOCK, LOW);
Serial.begin(9600);
}
void loop()
{
for (int i=0;i<=511;i++)
{
digitalWrite(CHIP_SEL ,HIGH);
shiftOut(DATA_OUT,CLOCK,MSBFIRST,READ); //sending READ instruction
shiftOut(DATA_OUT,CLOCK,MSBFIRST,low); //sending low address
byte incoming = shiftIn(DATA_IN,CLOCK,MSBFIRST); //receiving data
digitalWrite(CHIP_SEL ,LOW);
Serial.print(low);
Serial.print("/t");
Serial.print(incoming, BIN);
Serial.print("/t");
Serial.print(incoming, HEX);
Serial.println():
low++; //incrementing low address
}
while(1);
}
What I'm trying to understand is:
In the 93C66 datasheet page 5, table 6, it says that to read the contents of memory I need to send SB 1, OPCODE 10, and memory address, which I don't know exactly how to do, but I guess the chip wants a 110 (or a HIGH, HIGH, LOW signal) plus memory address (variable “low”=0). The SB and OP CODE are similar to the BYTE variable READ in the code above, but this variable has an extra 0 (1100). I tested the code with 110 and I get different incoming data. I also thought if BYTE is 8 bits then why not make the BYTE variable READ 11000000, but it changes the incoming data. So now I don't really know how exactly to send SB 1 and OP CODE 10. Need help with that.
Also, as you can see I'm printing the variable "low" and the variable "incoming" (in Binary and Hex) on one line, I thought it would be printing 1 bit per line, but it prints varying amounts of bits. Sometimes it would print 4 bits, 6 bits, or 8 bits, as in 1110, 11111111, 111100. I thought the line byte incoming = shiftIn(DATA_IN,CLOCK,MSBFIRST);
would get filled with 8 bits all the time, so when I Serial.print() it would have 8 bits, but it's not happening, why?
Also I thought the shifting in of the bits into the variable "incoming" occurs once in the for loop, or is there an inner loop in shiftIn()? I ask because I first made the for loop go for i=<4095, since there are 4096 bits in this EEPROM, but the increment of I doesn’t match the amount of bits I’m getting on each Serial.print() line. i.e. I would get something like this:
1 10111111 BF
I thought it would be getting something like this. (I’m thinking the shiftIn() of the 1st bit at address 0 happens when i=0, then 2nd bits gets shiftIn() when i=1, and so forth)
1 1
2 1
3 0
4 1
Etc, etc
How is shiftIn() shiftinf in the bits into the BYTE variable?
Thanks and sorry if it’s so many questions.