2010-03-28 03:26 PM
FLASH_ERROR_PG - what does that mean?
2011-05-17 04:44 AM
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. -Clive2011-05-17 04:44 AM
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
2011-05-17 04:44 AM
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 ;)2011-05-17 04:44 AM
Hi.
I don't get what you mean by this. Could you please elaborate - thanks. Thomas2011-05-17 04:44 AM
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.pdf2011-05-17 04:44 AM
>>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.2011-05-17 04:44 AM
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).2011-05-17 04:44 AM
>>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. -Clive2011-05-17 04:44 AM
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