Skip to main content
Malith Yapa
Associate
March 19, 2018
Question

HAL_FLASHEx_Erase() doesn't work consistently for sectors

  • March 19, 2018
  • 1 reply
  • 563 views
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
This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
August 10, 2018

Sorry, bumping old zombie unanswered questions off my feed

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