External EEPROM Interfacing With Arduino Uno

Hi,
I am try to interface BL24C02F external eeprom with arduino uno by using library wire.h
but i am unable to read or write from the device.
I get the same values which i store in rdata initially.

#include <Wire.h>
#define chipAddress 50

void setup()
{
Serial.begin(115200);
Serial.println("EEProm Data");
Wire.begin();
unsigned int cellAddress =0;
writeTo(chipAddress,cellAddress,10);
Serial.println("EEProm Data---");
Serial.print(readFrom(chipAddress,cellAddress),DEC);
Serial.println("EEProm Data11");
}

void loop(){}

void writeTo(int chAddress, unsigned int ceAddress, byte wData )
{
Wire.beginTransmission(chAddress);
Wire.write((int)(ceAddress >> 8)); // MSB
Wire.write((int)(ceAddress & 0xFF)); // LSB
Wire.write(wData);
Wire.endTransmission();

delay(10);
}

byte readFrom(int chAddress, unsigned int ceAddress )
{

Wire.beginTransmission(chAddress);
Wire.write((int)(ceAddress >> 8)); // MSB
Wire.write((int)(ceAddress & 0xFF)); // LSB
Wire.endTransmission();

Wire.requestFrom(chAddress,1);
byte rData = 0;
if (Wire.available())
{
rData = Wire.read();
}

return rData;
}

Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

I have locked your new topic on the same subject

Please post you code in code tags here rather than starting a new topic

#include <Wire.h>
#define chipAddress 50



void setup()
{
  Serial.begin(115200);
  Serial.println("EEProm Data");
  Wire.begin();
  unsigned int cellAddress = 0;
  writeTo(chipAddress, cellAddress, 10);
  Serial.println("EEProm Data---");
  Serial.print(readFrom(chipAddress, cellAddress), DEC);
  Serial.println("EEProm Data11");
}

void loop() {}

void writeTo(int chAddress, unsigned int ceAddress, byte wData )
{
  Wire.beginTransmission(chAddress);
  Wire.write((int)(ceAddress >> 8));   // MSB
  Wire.write((int)(ceAddress & 0xFF)); // LSB
  Wire.write(wData);
  Wire.endTransmission();

  delay(10);
}

byte readFrom(int chAddress, unsigned int ceAddress )
{


  Wire.beginTransmission(chAddress);
  Wire.write((int)(ceAddress >> 8));   // MSB
  Wire.write((int)(ceAddress & 0xFF)); // LSB
  Wire.endTransmission();

  Wire.requestFrom(chAddress, 1);
  byte rData = 0;
  if (Wire.available())
  {
    rData = Wire.read();
  }

  return rData;
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.