Page 1 of 2

"EEPROM" on f103cb/c8 rogers core, how to?

Posted: Mon Sep 28, 2020 11:26 pm
by Mangy_Dog
Hias, same project as the last one. I need to save some display configuration data, 6 32bit values. These configurations can only accurately be taken at run time (its touch sensor location configuring...)

I had a look at the only example included in rogers core EEPROM library. And I cant quite figure it out.
And having a bit of a google I couldnt find any real explanation of how to set it up.

It also has a config in the main header, but only mentions ze re and rd variants of the chip.

Anyone have a better guide on how to use it and set it?

Thanks

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Tue Sep 29, 2020 8:38 am
by stevestrong
Check the example from Rogers core: https://github.com/rogerclarkmelbourne/ ... xample.ino
You could edit the values for command 1 for C8T6 device here: https://github.com/rogerclarkmelbourne/ ... no#L40-L42
EEPROM addresses can be found in RM0008 chapter 3.3.3 page 55 table 5.

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Tue Sep 29, 2020 3:06 pm
by mrburnette

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Tue Sep 29, 2020 3:28 pm
by Mangy_Dog
In this project there wasnt enough space for fram or a real epprom.... And because its a set once config (most likely once) i didnt need a dedicated eeprom, I knew i could write to a spare space in flash, but the epprom library does that and makes it easy for the most part.

So steve if i understood that correctly.

I have a minimum of 1 whole page
I set the epprom area
EEPROM.PageBase0 = 0x0800 0000; // for the page 0 of the f103cb/c8 which is 1kb in size according to the datasheet

But a little confused with this bit...
EEPROM.PageSize = 0x400; // is this to set the whole size of the page 0 which would be 1kb 0x0800 03ff ? Or 400 as in the example?
Or is this a bit width setting in the page for saving data in clusters? So if i only need to save 32bits clusters I set this to 32?

Ok assuming its 400 for the whole page size, and im only declaring the page 0 for 1kb of space,

EEPROM.write(AddressWrite , DataWrite); // address write would be the explicit starting point for the data, and the end point would be what ever value i write? be it a 8 bit or 16 or 32 bit value? So i MUST make sure the next bit of data i write is 8 16 or 32 +1 above the first address?

So whats "EEPROM.PageBase1 =" for? What would stop you declaring pagebase0 and then making the page size larger like 2kb, the data would just overflow into the page1 space and work normally?

Or does the system only let you write a whole page at a time, you cant simply write chunks of data in the space? so for my 4x32bit values i need to basically shift them into a whole 128bit value, write them in then read it out and then shift split it back out?

And i guess if i only need 128 bits if i set my page size to 128 bits, would that free up the rest of the page for anything or is that just stupid :D

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Wed Sep 30, 2020 8:31 am
by stevestrong
I did not played around with that lib but what I remember to read from other users:
- the write cycles of the internal EEPROM is limited to ~10.000
- i think the data write happens in a size of 32 bits
- you can write only if you erase before the whole page where the data is writen to
- the lib uses two pages at the end of the flash area: - one page for a kind of table containing some offsets where the data is written in the other page, using al bytes of one page before erasing it again. Although I think the useful data is only 16 bits, the rest is for address management. So you can write data of 16 bit size only.
- the C8T6 family has the EEPROM organized in 1kB of data pages, that is why you need the value of 0x400. High performance MCUs have 2kB page size.

However, if you only need to write once or twice during development, you could simply write your own routine, check the HID and CDC bootloader source code for more detailes how to do that.

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Thu Oct 01, 2020 11:11 am
by Mangy_Dog
Thanks, ill look more into that too...
Tbh im only just prepping the code now, Ive still got tons of work to do refactoring the code ive already brought into this version. I still need to figure out some kind of master control routine for it all D:

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Sat Oct 03, 2020 10:13 am
by Phono
I have used a lot the simulated EEPROM library from Roger's core, and it worked perfectly. When I moved to STM32Duino, I found a port of this library that I have renamed EEPROM2 to avoid conflicts with the EEPROM library of the STM32 core. Since then, I am still satisfied with the operation, so I can recommend it.
It is very convenient since it handles everything silently. It is used as follows:
the memory cells are unsigned 16 bit values. A cell is identified by a 16 bit identifier.
When you write a value, the library searches for the identifier in the physical memory. If it is not found, it uses the first blank memory word and writes there the identifier and the value. It it were found, it overwrites the cell with a neutral value and searches for an empty cell to write the new value along with its identifier. If the new value is the same as the old value, it does nothing.
When the memory page is full, it automatically copies the values to the second memory page, and erases the first one.
Once you have understood that the identifier is not an address, the things are very simple. All you need is to give your values unique identifiers. You do not need to take care of making them contiguous. If you need to write larger values, e.g. 32 bit values, you create your own convention, e.g. the identifier x for the low word and the identifier x+100 for the high word.
Long story short, it is very convenient and very efficient. You can update a value more than 10,000 times safely, since each new value is written in a different memory location.
If you are interested I can send you the library.

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Tue Jan 04, 2022 5:34 pm
by Marian
Happy Birthday !..
I have stm32F103C8T6 ... blue pill ... Arduio IDE.
I'm still trying to save GPS data to EEPROM and I can't do it at all. The data appears on the console and on the LCD. Does anyone have the patience to help me?
I've tried many eeprom emulators ... and nothing ...
Thank you....
Be patient, I'm 65 years .

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Tue Jan 04, 2022 6:47 pm
by ag123
libmaple is ok, and decently lightweight on stm32f103, but it is mainly designed around stm32f103.
for the gps and eeprom, I'd suggest get a better board and run the 'official' core
https://github.com/stm32duino/Arduino_Core_STM32
boards could include things like Nucleos f401 or f411 RE boards, you can find the list on the core repository.
have more memory and flash. and has a faster cpu (it has an fpu and has 'art accelerator')

then for 3rd party boards there are the 'f401.f411 black pills' etc
https://stm32-base.org/boards/
there are offerings from Adafruit,
https://www.adafruit.com/product/4382
Pyboard
https://store.micropython.org/product/PYBv1.1
Olimex
https://www.olimex.com/Products/ARM/ST/
among others.
adafruit and pyboard are the 'micro' boards, but they stm32f405 have lots of flash and ram and runs fast - 168Mhz
https://www.st.com/en/microcontrollers- ... 405rg.html

for instance for the stm32f405, if you don't really have a lot of records to store, you could keep them in sram simply.
e.g. keep it in an array
And power it with batteries so that it won't turn off. and you could have your sketch respond to commands and simply
Serial.print() the array when you want to retrieve the data.

it is possible to store stuff in internal flash. 'official' core has the EEPROM library shipped with the core.
https://github.com/stm32duino/Arduino_C ... ies/EEPROM

Re: "EEPROM" on f103cb/c8 rogers core, how to?

Posted: Wed Jan 05, 2022 7:01 am
by Marian
ag123 wrote: Tue Jan 04, 2022 6:47 pm libmaple is ok, and decently lightweight on stm32f103, but it is mainly designed around stm32f103.
for the gps and eeprom, I'd suggest get a better board and run the 'official' core
https://github.com/stm32duino/Arduino_Core_STM32
boards could include things like Nucleos f401 or f411 RE boards, you can find the list on the core repository.
have more memory and flash. and has a faster cpu (it has an fpu and has 'art accelerator')

then for 3rd party boards there are the 'f401.f411 black pills' etc
https://stm32-base.org/boards/
there are offerings from Adafruit,
https://www.adafruit.com/product/4382
Pyboard
https://store.micropython.org/product/PYBv1.1
Olimex
https://www.olimex.com/Products/ARM/ST/
among others.
adafruit and pyboard are the 'micro' boards, but they stm32f405 have lots of flash and ram and runs fast - 168Mhz
https://www.st.com/en/microcontrollers- ... 405rg.html

for instance for the stm32f405, if you don't really have a lot of records to store, you could keep them in sram simply.
e.g. keep it in an array
And power it with batteries so that it won't turn off. and you could have your sketch respond to commands and simply
Serial.print() the array when you want to retrieve the data.

it is possible to store stuff in internal flash. 'official' core has the EEPROM library shipped with the core.
https://github.com/stm32duino/Arduino_C ... ies/EEPROM
Thanks so much for the guidance ...
I also found some code errors ...
A good day...