Hi All,
First of all I cant (or) not access our forum for few days Sorr.(Because I went to interview).
Ok.
Lets gets started.
Experiment:
SPI EEPROM Memory Interface with Arduino.
HW & SW :
Uno,24AA512 in Proteus simulator.(I don't have 24AA512 now. That is why)
Arduino 1.6.13
I am trying to interface SPI EEPROM Memory chip with my Arduino. I get and read the data sheet
Wiring :
uno---eeprom
SCK--SCK
MISO--SO
MOSI--SI
SS--CS bar
WP bar and HOLD bar is tied with VCC.
Here is my code
#include <SPI.h>
boolean once=false;
const int button=2;
const int led=3;
long int val;
void setup(){
pinMode(button,INPUT_PULLUP);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
SPI.begin();
delay(10);
SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0));
delay(10);
digitalWrite(SS,HIGH);
delay(10);
}
void loop() {
//Write Operation once
if(once==false){
digitalWrite(SS,LOW);
SPI.transfer(0x06); //WREN Enable Latch before write operation
digitalWrite(SS,HIGH);
delay(10);
digitalWrite(SS,LOW);
SPI.transfer(0x02); //Write Operation instruction
SPI.transfer16(0x0000); // 16-bit address location in eeprom (write)
SPI.transfer16(0xAA); // data. content to write
digitalWrite(SS,HIGH);
once=true;
}
//Read Operation
if(digitalRead(button)==LOW){
delay(10); // for prober debounce
digitalWrite(SS,LOW);
SPI.transfer(0x04); //WRDI Latch Disable write latch
digitalWrite(SS,HIGH);
delay(10);
digitalWrite(SS,LOW);
SPI.transfer(0x03); //Read Operation Instruction
val=SPI.transfer16(0x0000); // 16-bit address location in eeprom (read)
digitalWrite(SS,HIGH);
}
// Check the data is stored correctly
if(val==0xAA){
digitalWrite(led,HIGH); // if data is same this led glow
}
}
I cant get any response from my slave(I am using logic analyzer in Proteus).
Also Trying to enable the led if the data is written into that location.(My Led doesn't glow).
What is the mistakes I done ?. what I need to learn ?.
If you want I will share the wiring what I done in Proteus.
Thank you.