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.

Storing Array in Non-volatile memory

I am trying to store a 2D array in non-volatile memory.  Each entry in the array will be a uint8 and the whole array will be of the size 50 rows by 10 columns.  The process is that the client will write to a characteristic in my application with a array row and the 10 bytes of data and then my application will store this data in the appropriate row.  Then I will need to read this data later in the program. 

I am a bit confused on how to use the osal_snv_write function to do this.  Do I call this function as I declare the 2D array or just when I set the values?  What should be the parameter "id  - Valid NV item Id"? 

Would this work?

VOID osal_snv_write( 0x01, 10 , arrayrow1);

VOID osal_snv_write( 0x02, 10 , arrayrow2);

...

VOID osal_snv_write( 0x32, 10 , arrayrow50);

 

  • Valid NV item id is address in NV memory. 

    It should begin with 0x401.

    Applications can use 0x401- 0xFFF addresses , which is mentioned in OSAL API guide. Thus in above codes just change address and it should work .

    Easiest way is,

     VOID osal_snv_write( 0x401, 500 , &array);  // If you have continuous memory allocation.

  • That makes sense.  What if I want to incrementally enter the data.  So one 10 byte length at a time.   

    Will it be this: 

    VOID osal_snv_write( 0x401, 10 , &array1); 

    VOID osal_snv_write( 0x402, 10, &array2); 

    and so on...

     

    Or: 

    VOID osal_snv_write( 0x401, 10 , &array1); 

    VOID osal_snv_write( 0x411, 10, &array2); 

     

    Thanks for your help.  

  • Hi,

    It'll be as follow as it is bytewise memory. 

    VOID osal_snv_write( 0x401, 10 , &array1); 

    VOID osal_snv_write( 0x411, 10, &array2); 

    Thanks.