Pages: [1]   Go Down
Author Topic: i2c 24LC256 EEPROM Library - which one ?  (Read 1265 times)
0 Members and 1 Guest are viewing this topic.
Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Guys,

Trying to find the correct library to work in 1.04 with I2C EEPROM.

I have done a heap of searching but most of the libraries seem to be for the pre 1.0 environment and i am too much of a NOOB to know how to convert.

Does anyone have a known working Library for 1.04 that i can get pointed to please

(Any examples for a NOOb would also be much apppreciated)

Craig
Logged

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Guys,

OK i found this code which does not need an external library (other than i2c) and seems to work well.

Note it only handles single byte reads and writes - and does not implement the page write feature

Code:
#include <Wire.h>   
 
#define disk1 0x50    //Address of 24LC256 eeprom chip
 
void setup(void)
{
  Serial.begin(9600);
  Wire.begin(); 
 
  unsigned int address = 0;
 
  writeEEPROM(disk1, address, 123);
  Serial.print(readEEPROM(disk1, address), DEC);
}
 
void loop(){}
 
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data )
{
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.write(data);
  Wire.endTransmission();
 
  delay(5);
}
 
byte readEEPROM(int deviceaddress, unsigned int eeaddress )
{
  byte rdata = 0xFF;
 
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
 
  Wire.requestFrom(deviceaddress,1);
 
  if (Wire.available()) rdata = Wire.read();
 
  return rdata;
}
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


have a look at this - http://playground.arduino.cc/Main/LibraryForI2CEEPROM -

Not tested with 1.0.4 so please do, if it not works let it know
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


have a look at this - http://playground.arduino.cc/Main/LibraryForI2CEEPROM -

Not tested with 1.0.4 so please do, if it not works let it know

Thanks for the link - tried this one earlier and it does not work.

It uses the old send and receive methods rather than write and read.

I attempted to change those instances but then other errors were thrown up and it started getting too complex for me as a NOOB.

regards

Craig
Logged

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


have a look at this - http://playground.arduino.cc/Main/LibraryForI2CEEPROM -

Not tested with 1.0.4 so please do, if it not works let it know

Thanks for the link - tried this one earlier and it does not work.

It uses the old send and receive methods rather than write and read.

I attempted to change those instances but then other errors were thrown up and it started getting too complex for me as a NOOB.

regards

Craig


Actually i have resolved this now - but do not feel qualified to upload the results

1) the delay function was unknown - i remember reading about this somewhere so i did an include of the arduino.h in the header file - anyone know why this happens ?
2) You were using the Wiring.h library - i changed this to Wire.h and everything seems to work.

I have not checked what the example is meant to do (line by line) - but i definitely get sensible looking results on my terminal.

I think these changes need to be made to the download code to bring it in line with 1.x environment - but being a NOOB do not want to fiddle with it

Craig
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Actually i have resolved this now - but do not feel qualified to upload the results
You can PM me the code in a zip if you want, then I will refactor it if needed and make an update on the playground.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Craigcurtin,

Merged your code with the latest existing and updated the playground article with latest version - http://playground.arduino.cc//Main/LibraryForI2CEEPROM -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: