2013-11-25 08:50 AM
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
2013-12-02 04:02 AM
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 Regards2013-12-02 04:43 AM
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).
2013-12-02 05:22 AM
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.2013-12-02 05:33 AM
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.
2013-12-02 06:59 AM
foo.floatdata = 1.233;
Write foo.intdata -- Read bar.intdata float f = bar.floatdata;2013-12-02 07:21 AM
Ok, thanks very much.
It works now.Best Regards2014-07-12 01:52 PM
2014-07-12 04:21 PM
Single words were being written with the Standard Firmware Library, review the examples cited earlier.
2015-12-31 01:02 AM
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 you2015-12-31 05:06 AM
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.