cancel
Showing results for 
Search instead for 
Did you mean: 

Function to check flash page erased not working

mahirmahota
Associate

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;
}
 
1 ACCEPTED SOLUTION

Accepted Solutions
mahirmahota
Associate

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.

View solution in original post

3 REPLIES 3
mahirmahota
Associate

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.

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

Which part# specifically are you using?

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

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.