cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32F3xx Flash read and write uses but focussed around byte size operations

conrad c
Associate II

Hi ,

I ma looking at using the internal flash for EEPROM emulation, using Atolic and STM32F302cc

I have read the aplication note on eeprom emulation and quite a few stackoverflow discussion as well as a few ST community posts which seems to focus around the STM32F4xx series.

Having said this i also worked through the Cube example on FLASH erase Program. I understand the process and what it is doing including the align by 4 .

The code howver seems to erase the whole page , then wrtite the whole page , and then read the whole page.

if the page is 2048 bytes in size and starts at 0x0803f800 (taking the last page in to account). it will erase everything in there which is a problem if you want to focus only on a sector.

What i cant seem to find is how to only erase the the 4 byte sector. following the READ, MODIFY, ERASE WRITE pricipal

Do i always have to erase the full page ?

Can i only do a READ,MODIFY, Write operating on the 4 byte sector?

Do you perhaps have a sample of byte operations for this application ?

regards

Conrad

2 REPLIES 2
S.Ma
Principal

The main difference between EEPROM and FLASH is the number of erase cycle and the page size.

In EEPROM, the erase - write cycle is all done by HW and the page is automatically copied in a buffer (latches), modified by user, then reprogrammed in 5 msec tops.

Flash needs usually much more time to erase.

There are existing algos to emulate at best an EEPROM by a flash memory and they are documented.

Ask yourself how many times you plan to write in the eeprom over the life of the product, and how much data you plan to update. Calculate the eeprom needed area, the number of cycles.

Wear and tear can be improved at the expense of more used memory size.

Example: Imagine that each eeprom byte is in fact made of 8 bytes which XORed provide the user actual data. In this way, you can "write" 8 times a different data before having to trigger the erase.

If you use 2 pages, you might even think like "double buffering" and have pre-erased the other page to save time. Nothing's perfect, and when compromizes needs to be done, the well understanding of the needed good enough application functionality will make it a day.

>>Do i always have to erase the full page ?

Yes, you need to erase the larger unit.

>>Can i only do a READ,MODIFY, Write operating on the 4 byte sector?

No, you get to write the cells once after erasing them.

What you can do is a journalling, or accumulative write, where you have an array of structures which you incrementally write, to read you find the last one written to get the most current values, and you write the new ones back to the next slot.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..