stm32f767igt doesn't erase the flash
Hi All.
I work with stm32f767igt for using flash.
The code below is erasing and writing flash.
I succeed writing the flash.

But when i try to delete the flash with
HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) ;
and
FLASH_Erase_Sector(FLASH_SECTOR_10 ,FLASH_VOLTAGE_RANGE_3);
it didn't work properly.
So i can't update data in flash because flash doesn't deleted.
What am i doing wrong?
------------------------------------code ---------------------------------------------------------------------------------------
#define FLASH_BASE_ADDR ADDR_FLASH_SECTOR_10 /* Start @ of user Flash area */
#define FLASH_END_ADDR (ADDR_FLASH_SECTOR_11-1) /* End @ of user Flash area */
void flash_erase_write(void)
{
HAL_FLASH_Unlock();
// HAL_FLASH_OB_Unlock();
// HAL_FLASHEx_OBGetConfig(&OBInit);
// #if defined(DUAL_BANK)
// /* Turn on LED3 if FLASH is configured in Dual Bank mode */
// if((OBInit.USERConfig & OB_NDBANK_SINGLE_BANK) == OB_NDBANK_SINGLE_BANK)
// #else
// /* Turn on LED3 if FLASH is configured in Single Bank mode */
// if((OBInit.USERConfig & OB_NDBANK_SINGLE_BANK) == OB_NDBANK_DUAL_BANK)
// #endif
// {
// while(1);
// }
/* Get the 1st sector to erase */
FirstSector = GetSector(FLASH_BASE_ADDR);
/* Get the number of sector to erase from 1st sector*/
NbOfSectors = GetSector(FLASH_END_ADDR) - FirstSector + 1;
/* Fill EraseInit structure*/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = FirstSector;
EraseInitStruct.NbSectors = NbOfSectors;//NbOfSectors;
//FLASH_Erase_Sector(FLASH_SECTOR_10 ,FLASH_VOLTAGE_RANGE_3);
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) != HAL_OK)
{
printf("flash erase Error!!!\r\n");
while (1)
{
}
}
Address = FLASH_BASE_ADDR;
#define DATA_32 ((uint32_t)0x12345678)
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, DATA_32) == HAL_OK)
{
Address = Address + 4;
}
}
