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

how to store data[20][20] in flash using FDS

hi, i am working on code which require to store data array of 20x20 to store in flash area using FDS or any other possibilities.

1)i confused with FDS concept. how i can write data to flash during progrinamming nrf51 chip which is present in file.

2)HOW TO READ data[20][20] while running the program in after giving ble command to chip. and also i need to compare this data[20][20] with user sample values.

3)i was little confused proximity example bcoz it is using peer manager(i only need how fds working)is it possible to create a page with key and id for storing this data[20][20].

4)Can anyone provide example code with storing and reading array[2][2] at least. so that i can get knowledge on this FDS concept.

THANK YOU....

Parents
  • Here is an example that shows how to use FDS.

    For storing 2 dimensional array just declare the data for example as:

    static uint32_t m_data[2][2] = ...
    ...
    record_chunk.p_data         = m_data;
    record_chunk.length_words   = sizeof(m_data)/sizeof(uint32_t);
    

    The content will be stored sequentially (data[0][0], data[0][1] ... data[0][n], data[1][0], data[1][1] ...).

  • hi is it possible to store float array in fds. i am able to store int values but unable to store float values. i am using example in this link :- github.com/.../nRF52-fds-example

    i am writing float m_deadbeef[20][3]; //////(LIKE this i need to store 5 arrays and i should retrieve it back)

    here is how i am reading back data from FDS

    float *data;
    		
    uint32_t err_code;
    		
    		NRF_LOG_PRINTF("Start searching... \r\n");
    
    		
    // Loop until all records with the given key and file ID have been found.
    		
    while (fds_record_find(FILE_ID, REC_KEY, &record_desc, &ftok) == FDS_SUCCESS)
    		
    {
    				
    err_code = fds_record_open(&record_desc, &flash_record);
    				
    if ( err_code != FDS_SUCCESS)
    				
    {
    					
    return err_code;		
    				
    }
    				
    				
    NRF_LOG_PRINTF("Found Record ID = %d\r\n",record_desc.record_id);
    				
    NRF_LOG_PRINTF("Data = ");
    				
    data = (float *) flash_record.p_data;
    				
    for (uint8_t i=0;i<flash_record.p_header->tl.length_words;i++)
    				
    {
    					
    NRF_LOG_PRINTF("%f ",data[i]);
    				
    }
    				
    NRF_LOG_PRINTF("\r\n");
    

    i am getting emty data

Reply
  • hi is it possible to store float array in fds. i am able to store int values but unable to store float values. i am using example in this link :- github.com/.../nRF52-fds-example

    i am writing float m_deadbeef[20][3]; //////(LIKE this i need to store 5 arrays and i should retrieve it back)

    here is how i am reading back data from FDS

    float *data;
    		
    uint32_t err_code;
    		
    		NRF_LOG_PRINTF("Start searching... \r\n");
    
    		
    // Loop until all records with the given key and file ID have been found.
    		
    while (fds_record_find(FILE_ID, REC_KEY, &record_desc, &ftok) == FDS_SUCCESS)
    		
    {
    				
    err_code = fds_record_open(&record_desc, &flash_record);
    				
    if ( err_code != FDS_SUCCESS)
    				
    {
    					
    return err_code;		
    				
    }
    				
    				
    NRF_LOG_PRINTF("Found Record ID = %d\r\n",record_desc.record_id);
    				
    NRF_LOG_PRINTF("Data = ");
    				
    data = (float *) flash_record.p_data;
    				
    for (uint8_t i=0;i<flash_record.p_header->tl.length_words;i++)
    				
    {
    					
    NRF_LOG_PRINTF("%f ",data[i]);
    				
    }
    				
    NRF_LOG_PRINTF("\r\n");
    

    i am getting emty data

Children
No Data
Related