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

Example code for using Non volatile memory

I want to store a block of data in nRF51x22. I tried the following:

void HalStoreNVMBlock(uint32_t size, uint8_t* pBuf) { nrf_nvmc_page_erase(NRF_UICR_BASE); nrf_nvmc_write_bytes(NRF_UICR_BASE, pBuf, size); }

but after this code was executed the first time, I could not reprogram the device from Keil. I had to erase all using nRFgo Studio. Is there a code example for doing this?

Parents
  • When using a softdevice, the base address of the application is stored in UICR, and if you delete the entire UICR register, the softdevice will therefore no longer know where or how it can start the application.

    If you just want to store a little configuration data, you can use the upper bytes of the UICR register, but there is no convenient way to erase this part without erasing the rest of UICR.

    If you need to store and remove more data, I'd therefore recommend you to just use a normal flash page for this. There have been quite some discussion on how to do such flash writes in this question, so it might be worth having a look at. I believe that should be more or less sufficient to get going, but please let me know if anything is still unclear.

Reply
  • When using a softdevice, the base address of the application is stored in UICR, and if you delete the entire UICR register, the softdevice will therefore no longer know where or how it can start the application.

    If you just want to store a little configuration data, you can use the upper bytes of the UICR register, but there is no convenient way to erase this part without erasing the rest of UICR.

    If you need to store and remove more data, I'd therefore recommend you to just use a normal flash page for this. There have been quite some discussion on how to do such flash writes in this question, so it might be worth having a look at. I believe that should be more or less sufficient to get going, but please let me know if anything is still unclear.

Children
No Data
Related