cancel
Showing results for 
Search instead for 
Did you mean: 

flash read and write (urgent)

lakshmikantha85
Associate II
Posted on January 29, 2011 at 14:51

flash read and write (urgent)

4 REPLIES 4
Posted on May 17, 2011 at 14:23

There is a good example within Keil, and probably IAR too

C:\Keil\ARM\Examples\ST\STM32F10xFWLib\Examples\FLASH\Program\main.c

  FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);

    FLASHStatus = FLASH_ErasePage(0x08002000);

   FLASHStatus = FLASH_ProgramWord(0x08002000, 0x12345678);

Reading is just like any other memory, set a pointer to it and read, nothing magic.

u32 *mem = (u32 *)0x08002000;

printf(''%08X\n'', *mem);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 24, 2011 at 14:50

Hi,

My question is related to this thread. I want to store user data into flash and read it on power up. I suppose I can use the example you give to read and write, but my question is why did you choose memory address 0x08002000 ? Is that some random address? Where do I find the right address for storing data?

I have STM32F103RBT6 (which says 128k flash). In the Keil MDK of the example, I see in the configuration that the read/only memory area is from IROM1: 0x8000000 and size 0x20000. Also the read/write memory area is from IRAM1 0x20000000 and size 0x5000.

Thank you in advance.

Antonis

Posted on August 24, 2011 at 17:09

The 0x08002000 is an arbitrary address that works for pretty much the entire STM32 range. It may well have been picked by the original poster, but one of the forum crashes may have eaten the post, at least based on the timestamps. You can put your data anywhere you want. You should/could also shrink the space that Keil thinks it has available to protect the area you want to use.

For example shrink the allocation to 0x1F000 from 0x20000, and then use 0x0801F000 to store user data (up to 4KB in this example)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
keng1230
Associate II
Posted on September 23, 2011 at 04:49

now with something new error

.\Release\STM32F10x.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.

i am using this example 

C:\Keil\ARM\Examples\ST\STM32F10xFWLib\Examples\FLASH\Program\main.c