2015-11-11 08:41 AM
I have the following code:
FLASH_EraseInitTypeDef EraseInitStruct;
__HAL_FLASH_INSTRUCTION_CACHE_RESET
();
__HAL_FLASH_INSTRUCTION_CACHE_ENABLE
();
HAL_FLASH_Unlock
();
/* Get the 1st sector to erase */ // FirstSector = GetSector (Start_Addr); /* Get the number of sector to erase from 1st sector*/ // NbOfSectors = GetSector (End_Addr) - FirstSector + 1; uint32_t SectorError; /* Fill EraseInit structure*/ EraseInitStruct.TypeErase = TYPEERASE_SECTORS; EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; EraseInitStruct.Sector = FLASH_SECTOR_1; EraseInitStruct.NbSectors = 1;__HAL_FLASH_CLEAR_FLAG
(FLASH_FLAG_EOP | FLASH_FLAG_OPERR |
FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR); if (HAL_FLASHEx_Erase
(&EraseInitStruct, &SectorError) != HAL_OK)
{ return false; }FLASH_WaitForLastOperation
(10000);
uint32_t* ptr = (uint32_t*)0x8004000; uint32_t value = *ptr; if (value == 0xFFFFFFFF) { return true; } else { return false; }I expect this to make the value at address 0x08004000 read 0xFFFFFFFF but it doesn't.
Any ideas why not? I'm running this and stepping through to verify. Any help is much appreciated. D2015-11-11 09:40 AM
Any of the functions throwing errors, or timing out?
2015-11-11 03:57 PM
What debugger are you using?
Can you instrument the code and output status/progress via a serial port?