(nRF51822, but also concerned with nRF52832, SD130, SDK 12.1)
I'm trying to write/erase flash from a bluetooth event handler. As it's been outlined in other questions, while being in the event handler, other events aren't fired (like NRF_EVT_FLASH_OPERATION_SUCCESS), as outlined here: devzone.nordicsemi.com/.../ and in another much better answered question that I can no longer find.
So whenever I write/erase, I wait the following way:
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
nrf_delay_us(100);
}
After what I check the result (check that the whole page is FF, or check that my data was properly written). However, my issue is NRF_NVMC->READY is set to 1 very quickly, while the erase hasn't finished yet, causing my firmware to believe the flash erase failed (because the page is not full of FF).
Am I doing anything wrong? Any way to improve this? Thanks!