This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1352R: NVS driver: memory is different after successful write operation and power reset

Part Number: CC1352R
Other Parts Discussed in Thread: UNIFLASH, BLE-STACK

Tool/software:

Hello,

I am trying to store some data in the NVS memory area. 

To get the code running I used the code from the nvsinternal_CC1352R1_LAUNCHXL_tirtos_ccs example project.

This project uses the NVS.h driver functions.

Writing and reading works fine, but the memory area is altered after a power reset.

I am not using the debug mode since I read that it kills the nvs area as a default but connect to the already running target to watch my arrays and varialb

}

bool nvs(void)
{
    uint16_t offset = 0x50; //how do I know this does not clash with the bonding table?
	uint8_t readnvsData[8];

    static const uint8_t data[8] =
        {0x0F, 0x42, 0x3F, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A};
 

    bool res = true;
    NVS_Handle nvsHandle;
    NVS_Attrs regionAttrs;
    NVS_Params nvsParams;

    NVS_init();
    NVS_Params_init(&nvsParams);

    nvsParams2 = nvsParams;
    nvsHandle = NVS_open(CONFIG_NVSINTERNAL, &nvsParams);

    if (nvsHandle == NULL) {

        res = false;
    }

    NVS_getAttrs(nvsHandle, &regionAttrs);

    int_fast16_t resRead = NVS_read(nvsHandle, offset, (void *) readnvsData, sizeof(readnvsData)); // on first boot the bytes read here are all 0xFF, after power reset they should match the ones written below
    resRead = NVS_write(nvsHandle, offset, (void *) arrayToWrite, 8, NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
    resRead = NVS_read(nvsHandle, offset, (void *) readnvsData, sizeof(readnvsData));  // matches the written data from a column above
    NVS_close(nvsHandle);
    return res;

}

The content of the read array after the power reset:

I am calling this function right after the startup before BIOS_start();

I am not sure if the usage of the NVS driver is correct here since I saw that most people in the forum seem to use the oasl function which didn't work for me.

I read somewhere that some devices only allow multiples or 4 bytes for the write operation. 

Is this true for the CC1352R?

So far I see that no other module is using the NVS driver, can there be some settings somewhere though that could mess up my memory? The bondmanager perhaps?

I also played with the offset value, setting it to 0x2000 or 0x50 but the result stays the same.

Is there something I need to do before the power reset to lock the memory permanently? 

We use SimpleLink CC13x2 26x2 SDK v5.20.0.52 and cannot update to a newer one.

Thanks for the support

Miriam