Releases: teddokano/EEPROM_STM_Arduino
Release list
1.1.0
Update
update()method added. The single byte data is written only when the data is different from the existing one. Based on request from user. Unnecessary writing is avoided to make EEPROM life longer.
A picture below shows waveform when the update() called. The update() is called twice to try writing 0x00 and 0xFF into address 0x0A. The first time, the address 0x0A read and confirmed it has 0x00 already. So no write performed on this time. Second update() call reads address 0x0A and data is 0x00 which is different from should be written. A single byte write is performed to store 0xFF in address 0x0A.
eeprom.update( 0x0A, 0x00 ); // The address 0x0A is having 0x00. So no write will be performed
delay( 1 ); // delay added to show the transactions are separated by calls
eeprom.update( 0x0A, 0xFF ); // The address 0x0A holding 0x00. So the data 0xFF will be written1.0.1
Update:
write()method supports arbitrary address offset write over page boundary (version 1.0.0)- code simplified (version 1.0.1)
What is "write() method supports arbitrary address offset write over page boundary"?
In previous version, the byte address for multi-byte write need to be aligned to page-write size (16 bytes) boundary. From version 1.0.0, user doesn't need to care this limitation. User can write any size of data from any address.
The sample/test code of this new feature is available as examples/M24C02_test_arbitrary_address_write_over_page_boundary.
Example:
Next code is super simple version to see the difference.
It writes 50 characters of _ first and then 29 characters string is written.
#include "M24C02.h"
#include <string.h>
M24C02 eeprom;
constexpr int length = 50;
constexpr char test_str0[] = "Hello, M24C02! Is this work?";
char clear0[length];
char s[length];
void show_data(uint8_t *dp, int data_length) {
char s[2] = { 0 };
Serial.print(">> ");
for (int i = 0; i < data_length; i++) {
*s = *dp++;
Serial.print(s);
}
Serial.println("");
}
void setup() {
Serial.begin(9600);
while (!Serial)
;
Wire.begin();
Serial.println("\n***** Hello, M24C02! *****");
memset(clear0, '_', sizeof(clear0));
clear0[sizeof(clear0) - 1] = '\0';
eeprom.write( 0, (uint8_t *)clear0, sizeof(clear0));
eeprom.write( 8, (uint8_t *)test_str0, sizeof(test_str0));
eeprom.read(0, (uint8_t *)s, length);
Serial.println("read back from EEPROM :");
show_data((uint8_t *)s, length);
}
void loop() {
}In previous version (0.9.0), the read back data shows the data is corrupted because the address were not aligned to page-write size.
***** Hello, M24C02! *****
read back from EEPROM :
>> 24C02! IHello, Mork?___s this w_________________
Now in version 1.0.1 😃
***** Hello, M24C02! *****
read back from EEPROM :
>> ________Hello, M24C02! Is this work?____________
