cancel
Showing results for 
Search instead for 
Did you mean: 

using the flash as an EEPROM of STM32F3

hilwan
Associate II
Posted on November 25, 2013 at 17:50

Hi,

This is a post that was posted before in a wrong thread, this post was :

I would like to store my data in memory when the computing is done and used the data for the next use.

I don't have the EEPROM memory on my STM32F3, can i use the flash as an EEPROM?

Thanks in advance for any help.

Clive response was :

 

 

I don't have the EEPROM memory on my STM32F3, can i use the flash as an EEPROM?

Is that a design oversight, or you just don't want to attach one?

You could, however it is not designed for frequent, or multiple writing. Writing and Erasing Flash will cause the processor to stall quite significantly if you are also executing code from it.

ST has some EEPROM emulation examples, but they are not really designed for large structures.

fm response :

I don't have the EEPROM memory on my STM32F3, can i use the flash as an EEPROM?

 

In theory yes, but most probably not.

See the datasheet for FLASH erase/program times, which is in the millisecond range. For a higher data rate, you can evaluate serial SRAM/NVSRAM.

#stm32f3-discovery
19 REPLIES 19
hilwan
Associate II
Posted on December 02, 2013 at 13:02

Hi again,

With your help, now i can use the flash to write and even read. Thanks 

But, i still have a problem. In fact, i want to store float variables, unfortunately FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data) function allows only integers ones. How can i manage this stuff ?

Thanks in advance for any help,

Best Regards 

frankmeyer9
Associate II
Posted on December 02, 2013 at 13:43

As the ''Data'' parameter is passed by value, casting is probably not what you want here.

You could use a union instead:

union mydata
{
uint32_t intdata;
float floatdata;
};

... or combined with a typedef, if you like. However, to work the way intended, this 'non-portably' assumes that sizeof(float) == sizeof(unsigned int).
hilwan
Associate II
Posted on December 02, 2013 at 14:22

Thanks fm,

I don't understand your suggestion. What i want is when to store 1.233 for example, and the retrieved result from flash should be same.

frankmeyer9
Associate II
Posted on December 02, 2013 at 14:33

Unions are a basic C language feature, where you put two (or more) variable at the same location in memory. Thus, you can write a float value to the union, and read it out as int, or vice versa.

Posted on December 02, 2013 at 15:59

foo.floatdata = 1.233;

Write foo.intdata

--

Read bar.intdata

float f = bar.floatdata;
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hilwan
Associate II
Posted on December 02, 2013 at 16:21

Ok, thanks very much.

It works now.

Best Regards 

sinan
Associate
Posted on July 12, 2014 at 22:52

Hi could you share your flash programming  of your program  please.
Posted on July 13, 2014 at 01:21

Single words were being written with the Standard Firmware Library, review the examples cited earlier.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
deepakpatel2492
Associate
Posted on December 31, 2015 at 10:02

hie,

I am using stm32f303vc. I want to save around 300 bytes of structure into the flash. Structure contains mixed data types. I am not able to write a data more than 16 bits at a time. Is there any way to write whole structure into the flash at a time or is there any mechanism of page write . Please let me know regarding this.

thank you

Posted on December 31, 2015 at 14:06

You'd have to code a routine to copy the data, pretty sure the F3 permits 32-bit aligned writes. The RM or PM should cover the operational modes of the flash.

The flash does not care about the internal organization of your structure, write it as a sequence of words.

You could use the library code, or code your own, the PG bit doesn't have to toggle between each word write. In the scale of things that might not make a big difference as writing flash is not very rapid.

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