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
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frustrating for you and frustrating for us.
The people who try to help with your pro…
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;
}
system
Closed
December 31, 2021, 9:41am
5
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.