2014-10-22 04:35 AM
Hello.
I use STM32F4 and CoIDE. I use Flash sector 11 (because problem with linker when use sector 2) for store application parameters.I write code...FLASH_Unlock();FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);FLASH_EraseSector(FLASH_Sector_11, VoltageRange_3);FLASH_ProgramWord(0x080E0000, 12);FLASH_Lock();But, this is work only first time (after sector erase).How to rewrite variable without sector erase?Best regards,Cool Happy #stm32f #rewrite #flash #eeprom2014-10-22 05:07 AM
But, this is work only first time (after sector erase).
How to rewrite variable without sector erase?
You can't. Flash is designed to be only sector-erasable. Either use external EEPROM chips, which are byte/word erasable, or use an algorithm to work around your problem. For instance, write consecutive blocks/datasets, and use two Flash sectors in ping-pong mode. But keep in mind, the number of guaranteed erase/write cycles of Flash is limited.
2014-10-22 05:11 AM
According to RM0090 rev.7, ch.3.6.4 on p.86:
Successive write operations are possible without the need of an erase operation whenchanging bits from ‘1’ to ‘0’. Writing ‘1’ requires a Flash memory erase operation.
JW
2014-10-22 05:41 AM
:(((
OK. How to setup linker for this... sector 2 and sector 3 are eeprom, others main code?2014-10-22 05:57 AM
You'd have to create two discontinuous sections/segments, and direct specific sections/objects/functions into them.