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.

CC1352P: writing and reading flash memory in collector and sensor example

Part Number: CC1352P
Other Parts Discussed in Thread: SYSCONFIG

I have developed my own application using the collector and sensor application, but I want to write data to and read data from flash memory.When I download the nvsinternal example, I see NVS_write and NVS_read commands. I understand that I can write and read data to a specific address using these commands.However, in the collector part, data can be written using Main_user1Cfg.nvFps.writeItem as an example. But I cannot fully grasp this interface structure. The part I cannot understand is:

NVINTF_itemID_t id;
/* Setup NV ID */
id.systemID = memory_location_panid;
id.itemID = 0;
id.subID = 0;
/* write dynamicWeightThreshold */
Main_user1Cfg.nvFps.writeItem(id,sizeof collectorPanId, &collectorPanId);

I am writing data to memory with this command, but I don't understand which address I am writing to. Here, with variables like id.systemID, id.itemID, id.subID, I want to understand how I can determine where I am writing data. As you know, in the example, there are many values written and read to memory. I don't want to accidentally delete these variables. Therefore, I want to perform the write and read operations by explaining where and what I am writing. How can I achieve this?

  • Hi Mucahit,

    Apologize for the delayed response. If you check sysconfig and go to the nvs module on the left side, you will se the region base and region size. This is enough to prevent overwriting the data you want to keep. You know between which two memory addresses the data is stored in.

    Regards,

    Marvin

  • Actually, I am familiar with the region base and region size in sysconfig, but my current issue differs from that. I am involved in writing and reading the flash, yet I am uncertain about the exact flash address. In the provided example from the csf.h file, which is utilized in the collector example, there is a function as follows:

    bool Csf_getNetworkInformation(Llc_netInfo_t *pInfo)
    {
    if((pNV != NULL) && (pNV->readItem != NULL) && (pInfo != NULL))
    {
    NVINTF_itemID_t id;

    /* Setup NV ID */
    id.systemID = NVINTF_SYSID_APP;
    id.itemID = CSF_NV_NETWORK_INFO_ID;
    id.subID = 0;

    /* Read Network Information from NV */
    if(pNV->readItem(id, 0, sizeof(Llc_netInfo_t), pInfo) == NVINTF_SUCCESS)
    {
    return(true);
    }
    }
    return(false);
    }

    I believe these lines are responsible for writing and reading data from a specific address. However, I am unsure about the exact write and read addresses of the flash memory.

    I would like to understand how to calculate the position for this library using the id.systemId,id.itemId and id.subId ?

  • As you know, in the example, there are many values written and read to memory. I don't want to accidentally delete these variables. Therefore, I want to perform the write and read operations by explaining where and what I am writing. How can I achieve this?

    If you go into software_stack/15_4stack/nv/nvocmp.c you will find the APIs used to read and write to the NV items. It will help you understand how this interface works. NVOCMP_readItemApi() is the function to find out where in the flash a particular item is located. 

    I suggest you add in your own nvs module in sysconfig, so that you don't risk overwriting the flash data used by the stack.

    Regards,

    Marvin