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

nrf51422 strange behaviour of pstorage module

Hello, i am seeing a strange behaviour of pstorage module and i don't understand what is happening. I have read links below:

pstorage-problem-on-power-off
saving-data-reliably-with-pstorage
nordic-info-pstorage

However, that didn't help me to solve my issue. As i understand, pstorage module should allow us to write data to flash and save it, so when device is powered off and turned on again, we could load and use that data from flash. Correct? I put the example code which i'm testing, in case i am missing something. Store operation is working, i can see data being written to flash, starting from address 0x3FC00. Load operation is working, i can see the same data loaded to my flash_block0_data array. The strange thing happens when i am reaching advertising_init() function. My init code for advertisements is given below. after executing this line of code memset(&advdata, 0, sizeof(advdata)); in advertising init function, i see that my data block in flash memory starting from address 0x3FC00 are set to 0xFF. Means i am loosing my data which was stored in flash. What is happening here, what i am missing? Is this normal behaviour? Thanks for any help in advance.

Related