cancel
Showing results for 
Search instead for 
Did you mean: 

Write data on flash memory at execution time

ivancolla9
Associate III
Posted on February 03, 2016 at 15:20

Hello everyone,

in the past day I tried to save some data on the flash memory of the micro controller, but without results. Reading the documentation, I cannot understand exactly how I can write data on a specific address of the flash memory and retrieve it. I want to write 3 int 32 starting from 0x0008_0000, the High Address Space. My application is loaded on 0x0 of the flash, so I have space. At first I tried

*(ULONG*)0x00080000 = ulConfigValueTimeCrc;
*(ULONG*)0x00080004 = ulConfigValueStatCrc;
*(ULONG*)0x00080008 = ulConfigValueFlashCrc;

where the three values aare unsigned int (32 bit). I tried to retrieve them with

ulConfigValueTimeCrcLoaded = (*(ULONG*)0x00080000);
ulConfigValueStatCrcLoaded = (*(ULONG*)0x00080004);
ulConfigValueFlashCrcLoaded = (*(ULONG*)0x00080008);

The strange thing is that at 0x00080000 is written the correct value, but the other memory area remain to 0xFFFFFFFF. Another strange thing is that if I try other addresses in that address space (0x0008_0032, for example), the micro go in error. I tried, reading the manual, this procedure:

CFLASH.MCR.B.PGM = 1;
*(ULONG*)0x00080000 = ulConfigValueTimeCrc;
*(ULONG*)0x00080004 = ulConfigValueStatCrc;
*(ULONG*)0x00080008 = ulConfigValueFlashCrc;
CFLASH.MCR.B.EHV = 1;
while (CFLASH.MCR.B.DONE == 0)
{
/* Wait until the MCR DONE = 1 */
}
if (CFLASH.MCR.B.PEG == 0)
{
systemStatus->ubSystemStatus = IN_ERROR;
}
CFLASH.MCR.B.EHV = 0;
CFLASH.MCR.B.PGM = 0;

but with no results. Can someone see where the problem is with the examples above? Maybe someone can explain me better how writing on flash at execution time can be done. Thank you, Ivan #flash-memory-data
This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 REPLY 1
Erwan YVIN
ST Employee
Posted on February 22, 2016 at 15:52

Hello Ivan ,

Sorry for my late answer

You have some examples by installing the Flash Drivers in SPC5Studio Marketplace

(Cf Screenshot)

Others examples in the post .

[DEAD LINK /public/STe2ecommunities/mcu/Lists/SPC56/AllItems.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/SPC56/Using%20Data%20flash]https://my.st.com/public/STe2ecommunities/mcu/Lists/SPC56/AllItems.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSPC56%2FUsing%20Data%20flash

Best regards

Erwan

________________

Attachments :

2016-02-22_154913.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htfy&d=%2Fa%2F0X0000000aVe%2F7tSmZOt9ftmJo4sqWGtlMZESbLz0avmJxWu2cdDoa7w&asPdf=false