EEPROM Problem
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:
- Unlock the Data EEPROM and the FLASH_PECR register
- Write a word to a valid address in data EEPROM with the value 0x0000 0000
- This activates an erase phase
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-erase