Function to check flash page erased not working
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;
}