Illegal Flash Memory writes possible?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-02-09 4:02 AM
Posted on February 09, 2010 at 13:02
Illegal Flash Memory writes possible?
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:39 AM
Posted on May 17, 2011 at 13:39
so, finally I've got the bug :) and it was in my code.
The problem is, that after programming the Programm bit in the FLASH_CR register is still set and even if the FPEC is deactivated by setting the LOCK bit int the FLASH_CR register all further write to the memory will still be possible. So you must clear the programming bit to protect from accidently write operations to the flash. IMHO this is not exactly clear if you read the programming manual, further informations would be nice here. best regards thomasOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:39 AM
Posted on May 17, 2011 at 13:39
Yes, the general rule of thumb is to bracket any changes you make to the register, so you leave it in the state you found it.
FLASH->KEYR = KEY1; FLASH->KEYR = KEY2; FLASH->CR |= CR_PG; // Flash Stuff, write one word, multiple words, or the whole enchilada FLASH->CR &= ~CR_PG; FLASH->KEYR = 0; The Locking/Unlocking control access to the registers, they do not enable/disable the flash controller. The idea being that if your code runs amok it is not going to enable the controller, set it up, and trash itself. Or at least make the probability of that occurring pretty small. It is also possible to reprogram the entire flash memory while PG is enabled, it does not need to be toggled for every word written to memory, the library examples are not very efficient in this regard. -Clive
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
