I am working on an application where I need to do a one off calibration and save a few bytes of data. They will be written very rarely (probably only once) and read often.
I saw in the RTC thread there were a few bytes of storage available in memory which is kept alive by the RTC battery, however I would prefer to have this calibration data kept even if the RTC battery is replaced.
It seems ST have provided an app note detailing their ’emulated eeprom’ strategy: AN2594
And there is an implementation of it for Maple available: maple-eeprom-emulation-library
I’m going to investigate this further today and see if I can get it running.
As far as I was aware the EEPROM library was working.
https://github.com/rogerclarkmelbourne/ … ies/EEPROM
Page size on the Maple mini etc is 1k, and on the bigger (high density devices) its 2k.
[RogerClark – Mon Aug 03, 2015 9:23 pm] –
@C_DAs far as I was aware the EEPROM library was working.
https://github.com/rogerclarkmelbourne/ … ies/EEPROM
Page size on the Maple mini etc is 1k, and on the bigger (high density devices) its 2k.
G’day,
I noticed in the library “EEPROM” the lack of function “EEPROM.update” so I added in EEPROM.cpp the function:
Uint16 EEPROMClass :: update (uint16 Address, uint16 Data)
{
If (EEPROM.read (Address)! = Data)
{
EEPROM.write (Address, Data);
}
Uint16 status = EE_VerifyPageFullWriteVariable (Address, Data);
Return status;
}
And also added in the file “EEPROM.h” in the section EEPROMClass class:
Uint16 update (uint16 address, uint16 data);
Is this correct? Will it work?
Thanks for the wonderfull work “Arduino for the stm32”
[pablomuro – Thu Jul 13, 2017 2:15 am] –
G’day,
I noticed in the library “EEPROM” the lack of function “EEPROM.update” so I added in EEPROM.cpp the function:Uint16 EEPROMClass :: update (uint16 Address, uint16 Data)
{
If (EEPROM.read (Address)! = Data)
{
EEPROM.write (Address, Data);
}
Uint16 status = EE_VerifyPageFullWriteVariable (Address, Data);
Return status;
}And also added in the file “EEPROM.h” in the section EEPROMClass class:
Uint16 update (uint16 address, uint16 data);
Is this correct? Will it work?
Thanks for the wonderfull work “Arduino for the stm32”
The write function already includes this verification:
EE_VerifyPageFullWriteVariable (Address, Data);
So you don’t need that part, and could just return the value returned by write(). Such as:
return EEPROM.write (Address, Data);
English variant:
Help me! The feeds given after disconnecting dc power are not saved. After connecting the power while reading eeprom data = 0. That did I do not so?
I use Arduino IDE with the kernel stm32duino
code:
#include <EEPROM.h>
uint16 temp_set1_niz; uint16 temp_set1_verx;
void setup() {
EEPROM.init();
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x400;
}
void loop(){
temp_set1_niz = EEPROM.read(0x30, &temp_set1_niz); temp_set1_verx = EEPROM.read(0x40, &temp_set1_verx);
... There are data changes and then saving data ...
EEPROM.write(0x30, temp_set1_niz); EEPROM.write(0x40, temp_set1_verx);
}
&temp_set1_niz
temp_set1_niz[Pito – Sun Nov 12, 2017 2:21 pm] –
You mix
&temp_set1_niz
temp_set1_niz
When I select 3, read/write test, I sometimes get an 81 error (out of storage), and sometimes AB (no valid page).
Trying 2k worked once (status returned 0), but returned AB or subsequent attempts.
Is EEPROM emulation supported on Black Pill and Blue Pill boards?
If not, then what is the way to do it? There is always AT24Cxx I2C EEPROMs, but that means extra complexity and less pins.
Important.
Its just an emulation. If you treat it like a real EEPROM and issue thousands of erase / write cycles you will wear the flash memory out, very quickly as it only has 10,000 rewrite cycles – hence its not very usable for data logging.
However its fine for storing settings that don’t change very often
One thing of note is that the application (a telescope controller), uses the Arduino API, which uses 8 bit arguments, and then strings 2 or 4 of these for 16 and 32 bit values.
The wrapper code is here: https://github.com/hjd1964/OnStep/blob/Alpha/NV.h
This works for Arduino Mega 2560, and Teensy 3.x.
Then it would store things like this:
nv.write(offset1, false);
nv.writeLong(offset3, 15956313L);
I find the EEPROM library very limited.
What we should probably do is make a new libarary with some better functions, as really the process is..
READ PAGE TO RAM
UPDATE RAM WITH NEW DATA IN SOME PLACES
CHECK IF DATA HAS ACTUALLY CHANGED
IF DATA HAS CHANGED….
UNLOCK PAGE IN FLASH
ERASE PAGE IN FLASH
WRITE RAM TO FLASH
LOCK FLASH


