cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_FLASHEx_Erase() doesn't work consistently for sectors

Malith Yapa
Associate
Posted on March 19, 2018 at 13:15

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

#flash-sector
1 REPLY 1

Sorry, bumping old zombie unanswered questions off my feed

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..