This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Clearing UICR pages using the driver for the NVMC peripheral

Hello,

I know that this question has been asked in the past but I could not find any recent post about this topic, and there have been many updates to the SDK since the last asked one, so I hope it's okay to bring up this issue again.

I am trying to save a variable to non-volatile memory so that it's value will remain after a power cycle. This variable is not a constant and could change during runtime by user interference - the user will enter a new value to store over a UART interface. I am running my program with the s130 SoftDevice loaded.

I have been looking at the documentation for the nRF5 SDK V12.1.0, specifically, the documentation for the driver for the NVMC peripheral. It says on the page that the function nrf_nvmc_page_erase can be used to erase a page of the UICR. It takes an address of the page as an argument. I was able to use the function nrf_nvmc_write_word to write a 0 value to address 0x10001080 but I was unable to set it back to 0xFFFFFFFF by using the nrf_nvmc_page_erase function. The page address I passed to the nrf_nvmc_page_erase function was 0x10001080. That is the part I am unsure about - is the page address different from the address of a single memory block? Or am I doing something else wrong?

I figured that if a function exists to erase a page of the UICR, it must be possible. But I have gone through a lot of forum Q&As about this issue and everywhere, it said that I have to erase the entire UICR in order to clear it for re-use. Is that still the case? If so, what is my best bet for achieving my need of retaining a variable value upon losing power?

Thank you for your time.

Regards, Sid

Parents
  • Hi Sid Modi,

    the UICR registers of the nRF51x22 chips can only be erased by erasing the entire chip. This is stated in the nRF51 Reference Manual, Section 8.1

    The UICR can only be erased by using ERASEALL.

    My suggestion would be to use the sd_flash API to store the variable to flash ( not UICR) so that the value may be changed during runtime. A colleauge of mine has made an example showing how to this with the S120 SoftDevice, but it should be easy to port it to the S130. Here is the link to his example.

    Best regards

    Bjørn

Reply
  • Hi Sid Modi,

    the UICR registers of the nRF51x22 chips can only be erased by erasing the entire chip. This is stated in the nRF51 Reference Manual, Section 8.1

    The UICR can only be erased by using ERASEALL.

    My suggestion would be to use the sd_flash API to store the variable to flash ( not UICR) so that the value may be changed during runtime. A colleauge of mine has made an example showing how to this with the S120 SoftDevice, but it should be easy to port it to the S130. Here is the link to his example.

    Best regards

    Bjørn

Children
Related