Please use https://github.com/JChristensen/JC_EEPROM instead.
This repository is no longer maintained; it has been archived and is read-only.
Arduino library to support external I2C EEPROMs.
License: Other
This repository is no longer maintained; it has been archived and is read-only.
I've hotfixed it this way currently:
extEEPROM.cpp:
byte extEEPROM::begin(twiClockFreq_t twiFreq)
{
Wire.begin();
#ifndef LIBMAPLE_STM32_H
Wire.setClock(twiFreq);
#endif
Wire.beginTransmission(_eepromAddr);
if (_nAddrBytes == 2) Wire.write((byte)0); //high addr byte
Wire.write((byte)0); //low addr byte
return Wire.endTransmission();
}
https://github.com/rogerclarkmelbourne/Arduino_STM32/tree/master/STM32F1/libraries/Wire
Hi, great library. For EEPROMs >512k bits the chip is connected via A2 and A1 only and A0 is a "not connect". It is important that the chip address in extEEPROM is an even number.
ken
Hello,
It should be noted on the library page that the write function implemented (every byte is written separately) could case endurance problems.
For example 24LC256 datasheet clearly states that a byte write will force the entire page to endure a write cycle!
Note: When doing a write of less than 64 bytes,
the data in the rest of the page are
refreshed along with the data bytes being
written. This will force the entire page to
endure a write cycle, for this reason
endurance is specified per page.
Best regards,
amazed
When I tried to compile for the Arduino Due:
extEEPROM.cpp:99:7: error: 'TWBR' was not declared in this scope
TWBR = ( (F_CPU / twiFreq) - 16) / 2;
It compiles if I check if we are on an AVR:
#ifdef __AVR__
TWBR = ( (F_CPU / twiFreq) - 16) / 2;
#endif
However then I think the I2C speed would default to 100kHz (I'm not sure, I'm just starting to use the Arduino Due).
Hello @PaoloP74,
First at all, thanks for this great library.
I think there is a problem with .write() method; if external EPPROM is not connected, Arduino gets stuck in that function. Also the same thing with .update() and .read(); they must return error command, but never get stuck.
In my case, it's used in a long time project, and I wanna be sure that if for any reason EEPROM fail, my Arduino aren't not going to be stuck in that function (or restarting using watchdog).
Best regards!
Hello,
Wouldn't it be better if delay was moved after the conditional break?
This way 500us would not be wasted if eeprom write is already complete at the last iteration.
//wait up to 50ms for the write to complete
for (uint8_t i=100; i; --i) {
//delayMicroseconds(500); //no point in waiting too fast
Wire.beginTransmission(ctrlByte);
if (_nAddrBytes == 2) Wire.write(0); //high addr byte
Wire.write(0); //low addr byte
txStatus = Wire.endTransmission();
if (txStatus == 0) break;
delayMicroseconds(500); //new place for delay
}
Best regards,
amazed
Hi. I recently got a new board (FlutterWireless) that uses your library, it is based on SAM3S1A and during compile I get:
In file included from C:\Users\CyberPalin\Documents\Arduino\libraries\extEEPROM\extEEPROM.cpp:56:0:
C:\Users\CyberPalin\AppData\Local\Arduino15\packages\flutter\hardware\sam\0.1.3\libraries\Wire/Wire.h: In member function 'byte extEEPROM::read(long unsigned int, byte*, uint16_t)':
C:\Users\CyberPalin\AppData\Local\Arduino15\packages\flutter\hardware\sam\0.1.3\libraries\Wire/Wire.h:50:10: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)
uint8_t requestFrom(int, int);
^
C:\Users\CyberPalin\AppData\Local\Arduino15\packages\flutter\hardware\sam\0.1.3\libraries\Wire/Wire.h:47:10: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)
uint8_t requestFrom(uint8_t, uint8_t);
^
It doesn't seem to affect anything, but I never know for sure. Any help would be appreciated.
Thanks
Mike
Hi
i struggled to find a way to erase (ie zero out) eeprom contents page-wise.
i did not find another way than creating a buffer with zeros of the size of the eeprom block i wanted to erase. that'd be a huge waste of memory.
so i copied the ::write function of your lib to ::erase, removed the byte *value parameter and removed the line "values += nWrite; //increment the input data pointer" so the same, only one page wide buffer (in my case 128 bytes) is being written over and over again to the eeprom until all the eeprom area is zeroed out (in my case around 7k!).
please consider adding a fast-erase function to your lib or please point me in the right direction, if I missed something.
thanks!
Hello dear developer. You have got a very good library for working with an external EEPROM. Can you make an example of how to save any structure in the EEPROM no more than a page?
Error compiling example:
byte myData[10];
//write 10 bytes starting at location 42
byte i2cStat = myEEPROM.write(42, &myData, 10);
if ( i2cStat != 0 ) {
//there was a problem
if ( i2cStat == EEPROM_ADDR_ERR) {
//bad address
}
else {
//some other I2C error
}
}
there are no instances of the overloaded function "extEEPROM :: write", as well as the argument list C / C ++ (304)
Hi
when writing about 10k of data, the ESP8266 randomly resets (software watchdog). I tracked this down to the for loop "//wait up to 50ms for the write to complete" and changed it to this:
for (uint8_t i=50; i; --i) {
ESP.wdtFeed();
delay(1); //no point in waiting too fast
communication->beginTransmission(ctrlByte);
if (_nAddrBytes == 2) communication->write((byte)0); //high addr byte
communication->write((byte)0); //low addr byte
txStatus = communication->endTransmission();
if (txStatus == 0) break;
}
i read somewhere that the delaymicroseconds thing interferes with the ESP watchdog and so I changed it to delay(1), reduced the loop execution count to 50 and added ESP.wdtFeed();. so far no more resets happening.
Hello, just checked the library with a Microchip 24C16B and it works as it should
----------------
English Google Translate:
Hello,
I used this library that worked perfectly and my growing little by little program.
But now I find myself with mistakes every time.
I instantiate the library in this way "extEEPROM EEPROM( kbits_2, 1, 8 );" for my "ATMEL218 24C02N SU18" (YL-90).
No error is returned by "eeprom.begin( twiClock400kHz )" is when reading or writing, it changes ...
In reading, I have two cases:
- The reading goes well,
- I have only "9" errors returned.
This is not random, but it depends on the program that I put on the Arduino.
I add or remove rows and sometimes it works, other times not ...
In writing, I find myself all the time with the "9" error when I exceed the address "255" or I write a sequel that continues to this address, and what has been written before is either false or nothing is written (all at 255 value) ...
byte eread( unsigned long addr, byte *data, unsigned int len )
{
byte stat;
stat = eeprom.read( addr, data, len );
if ( stat )
{
Serial.print( "read " );
Serial.print( addr, DEC );
Serial.print( " -> " );
Serial.println( stat, DEC );
}
return ( stat );
}
byte ewrite( unsigned long addr, byte *data, unsigned int len )
{
byte stat;
stat = eeprom.write( addr, data, len );
if ( stat )
{
Serial.print( "write " );
Serial.print( addr, DEC );
Serial.print( " -> " );
Serial.println( stat, DEC );
}
return ( stat );
}
I can not find a solution, thank you in advance for your help.
----------------
French:
Bonjour,
J'utilisais cette librairie qui fonctionnait parfaitement et mon programme grandissait petit à petit.
Mais maintenant je me retrouve avec des erreurs à chaque fois.
J'instancie la librairie de cette manière "extEEPROM eeprom( kbits_2, 1, 8 );" pour mon "ATMEL218 24C02N SU18" (YL-90).
Aucune erreur n'est retourné par "eeprom.begin( twiClock400kHz );", c'est lors d'une lecture ou écriture, que ça change...
En lecture, j'ai deux cas de figure:
En écriture, je me retrouve tout le temps avec l'erreur "9" quand je dépasse l'adresse "255" ou que j'écris une suite qui continue sur cette adresse, et ce qui a été écrit avant est soit faux, soit rien ne s'est écrit (tout à la valeur 255)...
byte eread( unsigned long addr, byte *data, unsigned int len )
{
byte stat;
stat = eeprom.read( addr, data, len );
if ( stat )
{
Serial.print( "read " );
Serial.print( addr, DEC );
Serial.print( " -> " );
Serial.println( stat, DEC );
}
return ( stat );
}
byte ewrite( unsigned long addr, byte *data, unsigned int len )
{
byte stat;
stat = eeprom.write( addr, data, len );
if ( stat )
{
Serial.print( "write " );
Serial.print( addr, DEC );
Serial.print( " -> " );
Serial.println( stat, DEC );
}
return ( stat );
}
Je ne trouve pas de solution, merci d'avance pour votre aide.
Hi,
on ESP8266 and probably on other MCUs as well, you can opt in for software (bit banging) i2c just by doing Wire.begin(sda, scl).
please consider adding that to extEEPROM::begin().
i open with winRAR
and see this:
void eeRead(uint8_t chunk)
{
chunk &= 0xFC; //force chunk to be a multiple of 4
uint8_t data[chunk];
uint32_t val = 0, testVal;
Serial << F("Reading...") << endl;
uint32_t msStart = millis();
it looks like ALL Serial.print in the Example are damage!
i can repair it manually but when does it means
Serial.print or Serial.println ?
The change below allows compatibility with other processors like the M0 by using the
Wire.setClock() function to set the I2C bus speed. As TWBR is only available in the smaller AVR processors like the ATmega324P
(there is a pull request for this change by victorpv commented on 10 Sep 2017)
byte extEEPROM::begin(twiClockFreq_t twiFreq)
{
Wire.begin();
//TWBR = ( (F_CPU / twiFreq) - 16) / 2;
Wire.setClock(twiFreq); // TRL 21Oct2018, compatibility with other processors
Wire.beginTransmission(_eepromAddr);
if (_nAddrBytes == 2) Wire.write(0); //high addr byte
Wire.write(0); //low addr byte
return Wire.endTransmission();
}
http://ww1.microchip.com/downloads/en/AppNotes/01028a.pdf describes a way to Reset the 24LCxxx EEPROM. Any chance this library could do it?
Even using the underling Wire.cpp or the native twi.cpp seems not enough low level to transmit "9 bits". (i can only see TWI_WriteByte)
Not sure where to vent but Paolo74's fork of your library just showed up in the Arduino IDE as version 3.3.3. My code no longer compiles because the initialization fails to find the enumeration:
ee.begin(twiClock100kHz);
results in:
exit status 1
'twiClock100kHz' was not declared in this scope
Paolo74's fork doesn't allow issues to be raised so I thought I would raise it here. Hope you can forward this on or help explain why the newer library is failing.
HI Jack.
I validated your library with the 'Atmel AT24C256C (32k x 8)' component.
I tested it with our 'SmartEverything' board.
It works fine without any changes, if you would like to add it in your README.md
maybe with our Software Company name it would be great.
I also added, in my fork, ( https://github.com/searobin/extEEPROM )
a further example to trigger read and write operations from console,
If you think it could be useful, I can issue a pull request.
Hi, In my use case, EEPROM may not be connected at all times, and when I try to connect it, I cannot make my code continue working if EEPROM is not there to talk with, it stucks at .begin call and doesn't return status field.
Can this behaviour is overridable somehow? Or have anybody fixed this issue on their side?
In your readme, you claim "I/O across block, page and device boundaries is supported." However, when attempting to read from a device such as the ST Micro M24M02-02, you can't even get a full page!
It looks like everything is set up in the code properly to handle this, but using a byte to store length ruins it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.