Skip to main content
tkjmail2
Associate III
March 28, 2010
Question

FLASH_ERROR_PG - what does that mean?

  • March 28, 2010
  • 15 replies
  • 2285 views
Posted on March 29, 2010 at 00:26

FLASH_ERROR_PG - what does that mean?

    This topic has been closed for replies.

    15 replies

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    You can only write the half-word (16-bits) once, to overwrite it you must erase the page.

    The alternative is to write subsequent half word(s) beyond the last value by indexing through them to find the last thing written (0xFFFF). You could also use multiple half words in a structure if 0xFFFF might be an otherwise valid value for the data you are using. When you fill up a whole page, you could erase it an start over.

    -Clive

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    damh
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    An erased halfword (16 bit) can be indefinitely written with 0xFFFF.

    One time with 0<value<0xFFFF.

    And then indefinitely with 0x0000.

    So far it is sleazy flash. Normal flash can be changed bitwise, this one not. So you need up to 16 times more flash ;)

    tkjmail2
    tkjmail2Author
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    Hi Clive.

    Thanks for your response.

    If I wrote words (32-bit) instead of half-words, would it then be possible to overwrite it? Or do I have to erase a complete page to re-write it?

    Best Regards

    Thomas Jespersen

    swhite2
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    You have to erase the whole flash page before writing.

    Perhaps you should take a look at the manual.

    http://www.st.com/stonline/products/literature/pm/13259.pdf

    tkjmail2
    tkjmail2Author
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    Hi.

    I don't get what you mean by this.

    Could you please elaborate - thanks.

    Thomas

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    >>If I wrote words (32-bit) instead of half-words, would it then be possible to overwrite it? Or do I have to erase a complete page to re-write it?

    Basically no, if you want to change a value in flash you need to erase it. A smart algorithm would look to see if the current value matches the new one, and skip the write and/or erase of the location. Technically you can also overwrite patterns where 1 bits will be changed to 0, but not the other way around. On the STM32 you will however get an error when overwriting 0x1234 with 0x0234, but it looks to stick.

    The flash has finite write/erase cycles, so you can ''wear-level'' if you have an algorithm that rolls around writing to all locations in a page before erasing and starting over.

    -Clive
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    damh
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    Any flash in stm32f1xx

    In normal case (value!=0 and value!=0xFFFF) you can write only once per 16 bit (16 bit aligned).

    After this value have been programmed, you can only set all bits to zero (new value==0).

    damh
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    >>On the STM32 you will however get an error when overwriting 0x1234 with 0x0234, but it looks to stick.<<

    I don't understand this sentence. Writing 0x0234 over 0x1234 functions on your stm32? The 0x0234 can be read back from flash? The flash signals an error, but does write nevertheless?

    On my stm32f103xx the only way something is changed in a second write is, that i set all bits to zero.
    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    Depends on your lifetime erase/write expectations? 1,000 or 1,000,000

    The flash is perfectly fine for storing calibration data, configuration data, etc.

    Just be aware that erasing and writing it will slow down code executing in other parts of the flash. I think the 1MB STM32 has banks, you'd have to check.

    -Clive

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    tkjmail2
    tkjmail2Author
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:44

    Then what would your recommendation be when I have some Touch Screen settings that has to be saved in some kind of Non-volatile memory?

    Would you recommend me using an EEProm instead? Fx. the 24Cxxx, as I've got plenty of theese already?

    Thomas