Can´t erase data from flash memory (STM32)
I found the solution. I used HAL_FLASH_Lock() function instead of HAL_FLASHEx_Erase() function and it works fine. I also changed SECTOR because I was accidently erasing my program.

unit32_t address = 0x0800C000;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);

FLASH_Erase_Sector(FLASH_SECTOR_3, VOLTAGE_RANGE_3);

//----------------------------write data  
uint8_t data = 'A';
if (HAL_FLASH_Program(TYPEPROGRAM_BYTE, start_address, data) != HAL_OK) {
    HAL_FLASH_Lock();
    return;
}
HAL_FLASH_Lock();


Thanks for your help.