I find that library given in this topic.
I have some quaestions over this Eeprom emulation library.
1.) how to use this library? I looked in example but i got nothing.
2.) i hope this emulation doesn’t write over the original bootloader or deos it?
https://github.com/rogerclarkmelbourne/ … OM_example
else if (cmd == '1')
{
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x400;
DisplayConfig();
}
else if (cmd == '2')
{
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x800;
DisplayConfig();
}
" 1 set configuration to 0x801F000 / 0x801F800 / 0x400 (RB MCU)\r\n" \Thanks for your response
I wrote a library for them:
http://www.stm32duino.com/viewtopic.php?f=13&t=9
You need also a smd adapter board for them (total cheap on ali, I have 8 and 16pin boards and I need them all the time)
I suspect that with careful use of the emulated flash, i.e. only writing when absolutely necessary, even 10k cycles is going to be plenty for most use cases, since typically eerom is used for non volatile configuration information. Anything requiring more than a few write cycles per day, and its time to add external storage, or risk premature failure of the product. Back of the envelope calculation suggests 10,000 cycle flash life allows 27 cycles per day for a one year life span, 100,000 allows 270 cycles per day for a one year life span approx (13.5 or 135 per day for 2 year life, 6.7 or 67 per day for a 4 year life etc. for an STM or GD32 respectively). These figures also assume you are re-writing the same block every time.
Why two libraries?
First one is used with the STM32duino standard “software” I2c, the second one with hardware I2c (“HW” or “hardwire”).
Feel free to use them (hope, I’ve included the original author!)
#include <Wire.h> // for I2C
#define i2caddr 0x50 // device address for left-hand chip on our breadboard
byte d=0; // data to store in or read from the EEPROM
void setup()
{
Serial.begin(9600); // Initialize the serial line
Serial.println("I2c test");
delay (1000);
Serial.println("Start1");
Wire.begin(); // wake up the I2C
delay (1000);
Serial.println("Start2");
Serial.println("Writing data...");
for (int i=0; i<20; i++)
{
writeData(i,i);
}
Serial.println("DONE");
Serial.println("Reading data...");
for (int i=0; i<20; i++)
{
Serial.print(i);
Serial.print(" : ");
d=readData(i);
Serial.println(d, DEC);
}
Serial.println("DONE");
}
// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
{
Wire.beginTransmission(i2caddr);
// set the pointer position
//Wire.write((int)(addr >> 8));
Wire.write((int)(addr & 0xFF));
Wire.write(data);
Wire.endTransmission();
delay(10);
}
// reads a byte of data from memory location addr
byte readData(unsigned int addr)
{
byte result;
Wire.beginTransmission(i2caddr);
// set the pointer position
//Wire.write((int)(addr >> 8));
Wire.write((int)(addr & 0xFF));
Wire.endTransmission();
Wire.requestFrom(i2caddr,1); // get the byte of data
result = Wire.read();
return result;
}
void loop()
{
}
if yes, write a timestamp in the record block, maybe
repeat
write record
until end of eeprom
on subsequent writes, overwrite the oldest record
[z1rqdym – Thu Sep 17, 2015 7:06 pm] –
The reason to use an eeprom is to save pid gains. İf i change these gains every time via programming the board this spend me a lot of time. İ need to configure 9 gain. Only today i change these values 50 times. And can not find any gain usefull yet. For that reason i nees more r/w cycles on an eeprom or flash memory. İ bought microchip 24LC512 i2c eeprom . its memory is enough for mebut i should write a code to use them with i2cdevlib, because i use i2cdevlib to use mpu6050 to get dmp data.
Since you need to store PID coefficients, I assume you would store those as float values.
If you still want to use flash memory: I had the same question: viewtopic.php?f=28&t=3321
And there is the solution in that topic.
float int_to_float(int16_t input)
{
return (input / 10 + input % 10 * 0.1);
}

