cancel
Showing results for 
Search instead for 
Did you mean: 

Data in flash memory

federico.massimi
Associate III
Posted on March 14, 2017 at 11:41

Good morning,

   I'm working on a project with a STM32L476RGT6.

I need to save data in the internal flash memory, I just have to memorize some words and I would use one of the last sectors of memory.

What I want to know is how can I be sure that location is not occupied by the code? is there a way to set the compiler to not use certain memory locations for code and reserve it for the data? there are locations dedicated to data in which the compiler will never put code?

Thanks in advance.

Federico.
2 REPLIES 2
Nesrine M_O
Lead II
Posted on March 14, 2017 at 11:46

Hi

Massimi.Federico

,

What I want to know is how can I be sure that location is not occupied by the code? is there a way to set the compiler to not use certain memory locations for code and reserve it for the data? there are locations dedicated to data in which the compiler will never put code?

you can protect your memory area using Proprietary Code Read-Out Protection (PCROP): protection against read and write operations on Flash and SRAM memories.

For more details about PCROB of the STM32L4 series, I recommend you to have a look to

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fcontent%2Fccc%2Fresource%2Ftechnical%2Fdocument%2Fapplication_note%2Fgroup0%2F1f%2F99%2Fef%2Fd6%2F24%2F8d%2F44%2F08%2FDM00226247%2Ffiles%2FDM00226pdf%2Fjcr%3Acontent%2Ftranslations%2Fen.DM00226pdf

Application note.

-Nesrine-

Posted on March 14, 2017 at 13:17

Make the size of memory smaller in your IDE. ie if it were 128 KB (0x20000) and the sector was 16 KB (0x4000) you'd tell the system the target has 0x1C000 memory at 0x08000000. Then your data could be safely placed at 0x0801C000[0x4000] Pick sizes appropriate for your specific part.

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