cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Chip’s flash to store some data?

AMP HF
Associate II
Posted on May 17, 2017 at 07:54

Hi, I have chosen STM32F072RB for our project and I have use it in design. But now we must store about 128-byte data for the calibration of our device. STM32F072RB�s flash is 128K. it is too big for this application. So, I want to use its spare space to store these calibration data (128 bytes) and save an extern flash.

Now my issue is, how could this MCU store the data to its own flash?

Thanks.

#stm32f0 #calibration #flash
1 ACCEPTED SOLUTION

Accepted Solutions
Max
ST Employee
Posted on May 17, 2017 at 08:16

You should have look at these examples you can find inside the HAL library package:

STM32Cube_FW_F0_Base_Folder\Projects\STM32F072RB-Nucleo\Examples\FLASH

STM32Cube_FW_F0_Base_Folder

\Projects\STM32F072B-Discovery\Examples\FLASH

STM32Cube_FW_F0_Base_Folder

\Projects\STM32072B_EVAL\Examples\FLASH

and let us know if it does fit your needs or not.

View solution in original post

4 REPLIES 4
Max
ST Employee
Posted on May 17, 2017 at 08:16

You should have look at these examples you can find inside the HAL library package:

STM32Cube_FW_F0_Base_Folder\Projects\STM32F072RB-Nucleo\Examples\FLASH

STM32Cube_FW_F0_Base_Folder

\Projects\STM32F072B-Discovery\Examples\FLASH

STM32Cube_FW_F0_Base_Folder

\Projects\STM32072B_EVAL\Examples\FLASH

and let us know if it does fit your needs or not.

Max
ST Employee
Posted on May 18, 2017 at 08:38

The processor can directly read the flash memory, there is no special procedure.

Something like:

MyIntVariable = ( int *) 0x0801FFC0;

will copy an int from address 0x0801FFC0 (in flash) into MyIntVariable.

Of course it could be any other type and address...

AMP HF
Associate II
Posted on May 18, 2017 at 08:29

Hi Max, thank you for your response. The examples you offered are so helpful.

And I have another question based on this application.

I use the STM32F072RB with 128k flash. And the program flash address is from 0x08000000 to 0x0801FFFFF. It has 64 pages, 2K bytes per page.

If my code just need 10K bytes, is that mean the flash is empty or not used after 0x08002800?

Start        ->0x08000000

…(My code)

My code  ->0x08002800

…(Empty?)

End          ->0x0801FFFF

If it’s true the flash after 0x08002800 is not used, I plan to use the last few pages to store my calibration data.

Posted on May 18, 2017 at 08:44

You should check with your compiler/linker  map file to see what is actually used.

But basically, you are correct.

You should keep some margin in case you want to add features/correct some bugs in your program.