AnsweredAssumed Answered

HAL_FLASHEx_Erase() doesn't work consistently for sectors

Question asked by Malith Yapa on Mar 19, 2018

pEraseInit.TypeErase = TYPEERASE_SECTORS;
pEraseInit.Sector = 6;
pEraseInit.NbSectors = 1
pEraseInit.VoltageRange = VOLTAGE_RANGE;


pc.printf(".");

while(*(__IO uint16_t*)PAGE0_BASE_ADDRESS != 0xFFFF) {
    FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
    if (FlashStatus != HAL_OK)
    {
        return FlashStatus;
    }
    pc.printf(".");
    pc.printf(".");
}
pc.printf("\r\n");

I'm running the above code (simplified) as a part of an emulated eeprom on a nucleo-f746zg board. The eeprom sector (6 & 7) doesn't erase at all without the print statements. With the print statements it erases but sometimes after upto six iterations. I've tried disabling both caching and prefetching. With caching disabled it stops working completely.
I have tried changing the supply voltage parameter with no difference.

I have tried using the driver from the standard peripherals library (f4) with similar results.

 

Any guidance you can give on this would be much appreciated.

Compiler GCC_ARM

Outcomes