AnsweredAssumed Answered

[STM32F746BG] Accessing internal Flash from code

Question asked by foit.konrad on Apr 24, 2016
Latest reply on Apr 25, 2016 by teal.andy
Hi!
I'm programming STM32F746BG using IAR 7.40 and J-Link debugger.
I have a problem when trying to use internal flash to store some data. To be more specific when I try to erase sector 7. Here's my code:
01.HAL_FLASH_Unlock();
02.__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_ERSERR); 
03.FirstSector = 7;
04.NbOfSectors = 1;
05.EraseInitStruct.TypeErase     = FLASH_TYPEERASE_SECTORS;
06.EraseInitStruct.VoltageRange  = FLASH_VOLTAGE_RANGE_3;
07.EraseInitStruct.Sector        = 7;
08.EraseInitStruct.NbSectors     = 1;
09.if (HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) != HAL_OK)
10.{
11.  while (1)
12.  {
13.    HAL_Delay(100);
14.  }
15.}
Function (line 09) returns HAL_OK after short time (but noticeable, maybe few hunderd ms), but the memory is not erased. Sector 7 should start at address 0x080A0000, and there are still old data there.
However if I erase memory via J-Flash, it indeed contains only 0xFF and I can write new data which is stored.
I'll appreciate any help.

Best regards,
Konrad

Outcomes