2017-09-03 05:38 AM
Hello,
I use HAl_Flash driver on STM32L152RBT6 to read, write and erase internal flash memory(EEPROM).
when i try to write new data to flash, thatbitwise OR with previous value.
(
E.g. at address 0x08007000 pre-save =(int) 5, data =(int) 16 stored-value = (int) 21)
so i need to erase at the specified address before try to store new data on it.
In datasheet clearly explained how can erase
a word (unsigned int ** 4Byte).
Data EEPROM word erase
This operation is used to erase a word in Data EEPROM. To do so:
code:
uint32_t Address = 0x08007900;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
*(uint32_t *)Address = (uint32_t) 0x00;
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
�?�?�?�?�?�?
but it doesn't work.
if i set ERASE and PROG bits whole the page(256Byte) will be erased!
SET_BIT(FLASH->PECR, FLASH_PECR_ERASE);
SET_BIT(FLASH->PECR, FLASH_PECR_PROG);�?�?
what can i do for erasing 1 byte or 1 word?
thanks.
#eeprom #flash-eraseSolved! Go to Solution.
2017-09-03 11:30 AM
Perhaps you should be using the EEPROM, which is situated at 0x08080000..0x08080FFF ?
2017-09-03 07:19 AM
HAL_FLASHEx_DATAEEPROM_Unlock()
HAL_FLASHEx_DATAEEPROM_Erase(FLASH_TYPEERASEDATA_WORD,0x08007900);
2017-09-03 10:02 AM
Thanks to reply.
Also HAL_FLASHEx_DATAEEPROM_Erase() not erase anything. Just can erase full page but not a word or a byte.
2017-09-03 11:30 AM
Perhaps you should be using the EEPROM, which is situated at 0x08080000..0x08080FFF ?
2017-09-03 12:14 PM
thats right!
only 4KB of internal memory is EEPROM and 128KB is Flash memory.
thanks bro.