Simplified access to Microchip 24LCxx Serial EEPROM devices (I2C)

This library provides a simplified I2C access to a Microchip 24LCxx Serial EEPROM device. This sample illustrates how to use this library and the schema below shows the minimal implementation to run this sample. The I2C device address is 0xA0 + 0x01, where:

  • 0xA0 is the Microphip device address;
  • 0x01 is the configurable address set by <A0:A2> (In the schema below, A0=1 and A2=A3=0).

Note that you have toprovide the configurable address to the C24LCxx_I2C class constructor. The Microphip device address will be added automatically.

http://mbed.org/media/uploads/Yann/24lcxx_i2c_v0.2.jpg

Note that if the LPC1768 is powered in 3.3V and the Microchip 24LCxx Serial EEPROM device could be powered at 3.3V or 5V.

In this case, you shall use a bi-directional level shifter for I2C-bus. Please refer to AN97055 (http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf)

Microchip 24LCxx Serial EEPROM device reference:

  - 24LC256: DS21203K

  - 24LC64 : DS21189D

For I2C details, please visit http://www.datelec.fr/fiches/I2C.htm


25 Nov 2010

Thanks a lot for your work on this.

Only one correction: The address is 0xA0 + 0x01 in the picture.

 

br

 

25 Nov 2010

Hello Thomas,

You're right, thanks a lot for your remark, it's fixed now.

Br,

Yann

26 Nov 2010

Hi,

in your sample you use a header-file. Where can I locate this?

br

27 Nov 2010

Hello Thomas,

Sorry for the delay.

I use the following header files:

  • #include "24LCxx_I2C.h"
  • #include "EthernetNetIf.h"
  • #include "NTPClient.h

The first is the 24LCxx_I2C header

The second is the header provided by the EthernetNetIf library.

The third is also provided by he EthernetNetIf library.

Best regards,

Yann

01 Dec 2010

Hello Yann,

where can I find the 24LCxx_I2C.h - file? It is not part of the library.

br

 

01 Dec 2010

Hi Thomas,

Sorry for the delay, I'm currently in Munich (snowing snowing...)!

It's strange, I've done an import in a new created project, after you edit the library (right click) and there are both header and code files.

Tell me if your problem persists, I'll send you an archive of the library.

Have a good day,

Yann

03 Dec 2010

Dear Yann,

I had tried every time the link to the sample-programm above.

Now I take a look to yout Name and than the lib.

There the file is located.

Thanks

12 comments on Simplified access to Microchip 24LCxx Serial EEPROM devices (I2C):

24 Feb 2013

Can you upload an sample code?

as far as i read from the datasheet that 8th bit is the mode select bit i.e. it will be written or read. How could you use this bit as address?

24 Feb 2013

Dear Razu,

Please find sample application code here.

Don't hesitate to contact me if you got any problem.

Best Regards, Yann

04 Mar 2013

Hi Yan,

I've started to look at your code to see if I can use it to store some simple data between restarts (I'm planning on putting the code on an LPCxpresso board that doesn't have the mBed storage)

When I imported the library I found it also required your DebugLibrary, and after install that as well, I got the following error: "no instance of constructor "mbed::I2C::I2C" matches the argument list" in file "24LCxx_I2C24LCxx_I2C.cpp", Line: 40, Col: 58

I also had a go at getting your example app to run as well, when importing the program I got the following error: Unable to update the library to revision: /24LCxxI2CApp/24LCxxI2C

And when compiling the program I got about 30 Errors such as: "name followed by "::" must be a class or namespace name" in file "/main.cpp", Line: 15, Col: 36 "incomplete type is not allowed" in file "/main.cpp", Line: 15, Col: 5 "expected a ")"" in file "/main.cpp", Line: 15, Col: 56

My C++ isn't great, so I found the app a bit impenetrable, do you have a simple HowTo covering how you read and write to/from one of these chips?

Many thanks,

Matt

07 Mar 2013

Hi Yan, thanks for posting your code and dealing with the support issues!

I am getting the same error as above, namely "no instance of constructor "mbed::I2C::I2C" matches the argument list" in file "24LCxx_I2C24LCxx_I2C.cpp", Line: 40, Col: 58" and I am using the Debug library too.

this is using an NGX Technologies board with an AT24LC256 chip - but the compiler won't get as far as that yet....

#include "mbed.h"
#include "TextLCD.h"
#include "24LCxx_I2C.h"

TextLCD lcd(p23, p24, p25, p26, p29, p30, TextLCD::LCD16x2); //If using the NGX board.

//C24LCXX_I2C(const PinName p_sda, const PinName p_scl, const unsigned char p_address, const PinName p_wp = NC, const int p_frequency = 400000); C24LCXX_I2C(const PinName p_sda, const PinName p_scl, const unsigned char p_address, const PinName p_wp = NC, const int p_frequency = 400000);
C24LCXX_I2C mem(p13, p14, 00000100, NC , 400000); 
DigitalOut myled(LED1);

std::string text2save("Hello World");
std::string readtext;


int main() {
        
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("%s", text2save);
        mem.Write(1, text2save, true, -1);//Write(const short p_address, const unsigned char *p_datas, bool p_storeLength = true, const int p_length2write = -1);
        wait(0.2);
        mem.Read(1, readtext);  
        lcd.locate(0,1);
        lcd.printf("%s", readtext);
}      
13 Aug 2013

Hi, I've been considering using one of these eeproms so took a look at your library, I didn't understand why you add 1 to the address when performing a write operation?

19 Aug 2013

Hello Robin,

My apologies for the delay, I was in vacation. I'm going to check it and I'll come back to you asap.

have a nice day,

Yann

20 Aug 2013

Dear Robin,

My apologies for the delay. Please, find here (/media/uploads/Yann/testrobin.zip) the library with a very simple test program. May I ask you to run it with your hardware to check it works fine? Find also here (/media/uploads/Yann/i2c.txt) the I2C analyze of an execution of this test program.

Hope it helps you,

Have a nice day,

Yann

20 Aug 2013

Matthew Green wrote:

Hi Yan,

I've started to look at your code to see if I can use it to store some simple data between restarts (I'm planning on putting the code on an LPCxpresso board that doesn't have the mBed storage)

When I imported the library I found it also required your DebugLibrary, and after install that as well, I got the following error: "no instance of constructor "mbed::I2C::I2C" matches the argument list" in file "24LCxx_I2C24LCxx_I2C.cpp", Line: 40, Col: 58

I also had a go at getting your example app to run as well, when importing the program I got the following error: Unable to update the library to revision: /24LCxxI2CApp/24LCxxI2C

And when compiling the program I got about 30 Errors such as: "name followed by "::" must be a class or namespace name" in file "/main.cpp", Line: 15, Col: 36 "incomplete type is not allowed" in file "/main.cpp", Line: 15, Col: 5 "expected a ")"" in file "/main.cpp", Line: 15, Col: 56

My C++ isn't great, so I found the app a bit impenetrable, do you have a simple HowTo covering how you read and write to/from one of these chips?

Many thanks,

Matt

20 Aug 2013

Dear Matthew,

My apologies, I fully missed your post. So please find here (/media/uploads/Yann/testrobin.zip ) a more simple test application of the 24LCxxI2C library. I aked Robin to validate it with his hardware. If all works fine, I'll publish this new simplest version.

Have a nice day,

Yann

20 Apr 2015

Hello Yann Garcia,

I am new to mbed an trying to figure out EEPROM and Real Time Clock. The eeprom i wish to use is "24C512" and the RTC is from adafruit DS1307... DS1307 library is not hard to find and reachable from Cookbook menu...

Where or how can i find a simpe library for 24C512? I just need to write, read and erase single bytes for configuring the control system.

Thank you for support :)

31 Aug 2016

Hello Yann Garcia,

I use a STM32 Nucleo F303K8, without internal EEPROM and I want to use an external Microchip 24LC256 connected torugh I²C. I wrote a small testprogram: - read an Analogue value of a potmeter (0.0->1.0) - multiply this value with 255 to get 0x00->0xFF - store this value in the EEPROM - read this back out of the EEPROM - devide this value again by 255 to get again a value from 0.0->1.0

I used your library but when I want to compile I get always the same error. Code is below, please can you help me?

/media/uploads/kcnypmeknaj/eeprom_i-c.jpg

03 May 2017

Hello Yann Garcia,

I wish to use your library to interface my Nucleo 401 board to a module containing AT24C32 chip + RTC DS3231 chip. The objective is to show simple read/write I2C operations to my students. RTC code and library is doing just fine. We usually compile in mbed and then export project to keil uV5 so that we can do better debugging.

When I compile your example code and library (including debug library) , the whole project code becomes about 50K. Students use Keil evaluation version which is code limited to 32K bytes and hence it can not be run.

Is there any leightweight library which provide rudimentary read/write functions and takes much less space than current version?

Thanks in advance -Prakash W Dandekar

Please log in to post comments.