Skip to content

Commit b4ab3eb

Browse files
committed
Update auto-detect info.
1 parent 6dd781a commit b4ab3eb

File tree

3 files changed

+309
-121
lines changed

3 files changed

+309
-121
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ Best used with the Qwiic EEPROM: https://www.sparkfun.com/products/18355
1313

1414
This library can be installed via the Arduino Library manager. Search for **SparkFun External EEPROM**.
1515

16+
The method for autodetection is as follows. The original data on the EEPROM is maintained once autodetection is complete:
17+
18+
* Address Bytes: Smaller EEPROMs use one address byte and larger EEPROMs use 2 address bytes. The auto-detection routine attempts to read a byte and then write a new byte. If the read/write fails, the address byte count is increased and a write attempt is tried again. Once the correct number of address bytes is detected, the original value is written back to EEPROM.
19+
20+
* Page Size: 256 bytes of EEPROM are read individually (to avoid page reads). Then, new bytes are generated that are random *and* different from the original data. The new bytes are written to EEPROM in increasing page size tests (8 bytes, then 16, etc) until the data does not match. Then the original data is written back to the EEPROM. Note: The page size may be reported as 32 bytes when the actual page size is larger. This is because of the size of the I2C buffer available on your microcontroller's Arduino core's Wire implementation. On some platforms (such as Arduino Uno) the I2C write buffer is 32 bytes. Once the two write bytes are removed, that leaves only 30 bytes available for sequential reads/writes. For maximum write speeds, use a platform that has a larger buffer than the page size of the EEPROM you are using.
21+
22+
* Memory Size: Once address bytes and page size are determined, single bytes are read, then written, then checked at the end of the potential EEPROM space. For example, byte 65535 is read for its original value and stored. Then a new, different value is written to location 65535. If the read/write fails, we know the EEPROM is one size down (32768 bytes, aka 24XX256).
23+
24+
* Page write time: This setting is not detected at begin(). All EEPROMs have a max write time of 5ms. Testing with a logic analyzer has shown that all EEPROMs respect this max and have an average of ~4.5ms for a page write. Attempting to trim the page write time lower than 5ms is much less worthwhile than using up a properly sized page size setting with an adequately sized I2C write buffer. In other words, read and write as many bytes as the page size can handle, don't worry about setting the page write time to 4ms or 5ms. Note: The 24XXM02 has a 10ms max page write time.
25+
1626
Want to help? Please do! We are always looking for ways to improve and build out features of this library.
1727

1828
Thanks to:

0 commit comments

Comments
 (0)