I tried writing a value to the Flash memory, initially i wrote 0x0000 to the position i mentioned in code it was successfully written but after that i'm not able to overwrite or erase the data in that position.So for the First time i could write to Flash successfully but after that i couldn't write /erase data in that location .What may be issue? I've pinned the memory stack image also.
uint32_t pageAddress = 0x08008000;
uint16_t buffer = 0xdddd; // data buffer
HAL_HAL_StatusTypeDef status;
while(1)
{
HAL_FLASH_Unlock(); // unlock the flash memory in ST
//FLASH_PageErase(pageAddress);
status=HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, pageAddress,
buffer);
HAL_FLASH_Lock(); // Flash memory locked
}