This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Knowing NVMC operation is finished inside BLE event

(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!

Parents
  • Thanks! I will investigate that lead! I know ideally it should be out of the event handler, however that makes the complete code considerably more complex, splitting everything into a lot of callbacks. Down the road I'll probably resort to it but if in the the meantime I can avoid it, I will...

Reply
  • Thanks! I will investigate that lead! I know ideally it should be out of the event handler, however that makes the complete code considerably more complex, splitting everything into a lot of callbacks. Down the road I'll probably resort to it but if in the the meantime I can avoid it, I will...

Children
No Data
Related