Skip to main content
federico.massimi
Associate III
March 14, 2017
Question

Data in flash memory

  • March 14, 2017
  • 2 replies
  • 523 views
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.
    This topic has been closed for replies.

    2 replies

    Nesrine M_O
    Associate
    March 14, 2017
    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-

    Tesla DeLorean
    Guru
    March 14, 2017
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..