2016-04-24 09:54 AM
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:
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_ERSERR);
FirstSector = 7;
NbOfSectors = 1;
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = 7;
EraseInitStruct.NbSectors = 1;
if
(HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) != HAL_OK)
{
while
(1)
{
HAL_Delay(100);
}
}
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 address0x080A0000, 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
#flash #stm32f7 #erase
2016-04-24 10:50 AM
Little update.
Moving ROM to sector 2 (0x08010000) and data to sector 1 (0x08008000) is kinda a workaround, this works.You should not use sector 0 to store data, because (in my case) IAR startup code sits at 0x08000000.However trying to erase sectors 6 or 7 (memory from 0x08070000) still ends with nothing.2016-04-25 10:11 AM
Think you are looking at the wrong memory addresses.
The STM32F746 is this:#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08080000) /* Base @ of Sector 6, 256 Kbytes */#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x080C0000) /* Base @ of Sector 7, 256 Kbytes */