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

storing a big array in the flash memory

Hi, i need to save an array of 50 kB on the nrf51822 flash. I only need to read the data stored in the array. I come from the PIC micro world where i simply need to initialize the array as " const " and the compiler would take care of storing the array. How can i do the same with the nrf51822?

  • If you only need to read you can use const to store a array in flash. Remember to initalize it when you declare it, and that it can be optimized away if it is not used.

    If you need to write it depends on if you are using a Softdevice(S1xx, S210, S310) or not.

    If not, you have two options. You can access the Non-Volatile Memorty Controller (NVMC) registers directly, or you can use the NVMC driver. It is named nrf_nvmc in the SDK, and you can find its documentation here.

    If you are using a SoftDevice you should use Persistent Storage Manager. It is named pstorage in the SDK, and you can find its documentation here.

    Edit: added const possibility.

Related