Skip to main content
Graduate
May 15, 2025
Solved

Function to check flash page erased not working

  • May 15, 2025
  • 1 reply
  • 521 views

I have the following function to verify that a full flash sector is erased but the code never seems to exit this function and I believe it gets stuck at the point where I dereference the address value. What could be the issue?

static bool check_sector_erased(uint32_t sector_base) {
 bool ret = true;
 uint32_t sector_end = sector_base + SECTOR_SIZE;
 uint32_t addr_val = 0;

 for (uint32_t address = sector_base; address < sector_end; address += 4) {
 addr_val = (*(volatile uint32_t*)address);
 if (addr_val != ERASED_32) {
 ret = false;
 break;
 }
 }
 return ret;
}
 
    This topic has been closed for replies.
    Best answer by mahirmahota

    Update, I was reading virgin memory in high cycle flash which cause the ECCD to trigger an NMI. I suppose my follow up question would be is there a way to temporarily disable the interrupt instead of handling it? Setting the ECCNMI_MASK_EN bit in the SBS_ECCNMIR didn't seem to achieve anything.

    1 reply

    mahirmahotaAuthorAnswer
    Graduate
    May 15, 2025

    Update, I was reading virgin memory in high cycle flash which cause the ECCD to trigger an NMI. I suppose my follow up question would be is there a way to temporarily disable the interrupt instead of handling it? Setting the ECCNMI_MASK_EN bit in the SBS_ECCNMIR didn't seem to achieve anything.

    Graduate II
    May 15, 2025

    I suspect you could just return instead of infinite looping..

    Which part# specifically are you using?

    Graduate
    May 15, 2025

    I'm using an H533. I have it set up now to have a global disable_eccd flag that, when set true, causes the NMI to clear the register and return. This works but I feel like it'd be cleaner if there was a way to disable NMI for the error temporarily altogether so was just wondering.