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

Get data from BLE and write to flash memory using pstorage

Hi,

I am having trouble to use flash to store data.

First, I write function and scan beacon, get information from this beacon and save to flash

I use a timer for saving data to flash but it is not work, I always get the error code = 0x00000010. It means "invalid flag". How can I solve this problem?

Thanks and regard

Parents
  • Where do you get this error, in pstorage call or somewhere else? Can you please post that piece of code where the error is generated?

  • Hi Aryan,

    Error when I call pstorage function in timer handler function

    void Freq_timer_handler(void * p_context)
    {
    	  app_beacon_scanner_stop();
    	  uint32_t                retval;
    		retval = pstorage_init();
    		   
    		param.block_size  = 16;                   
    		param.block_count = 10;                   
    		param.cb          = example_cb_handler;
    			
    		retval = pstorage_register(&param, &master_handle);
    		
    		
    		   //Get block identifiers
    		   retval = pstorage_block_identifier_get(&master_handle, 0, &block_0_handle);
    			
    		   retval = pstorage_clear(&block_0_handle, 16);                   //Clear first registered page. A pstorage_clear command must operate within a single page
    		   retval = pstorage_wait_handle = block_0_handle.block_id;            //Specify which pstorage handle to wait for 
    		   retval = pstorage_wait_flag = 1; 
    		   retval = pstorage_store(&block_0_handle, source_data_1, 16, 0);     //Write to flash	
          			 
    			 for (int i = 0; i < 16;i++)
    			 {
    				  source_data_2[i] += 1;
    			 }
    			 retval = pstorage_block_identifier_get(&master_handle, 0, &block_0_handle);
    			 retval = pstorage_load(temp, &block_0_handle, 16, 0);
    

    ........

Reply
  • Hi Aryan,

    Error when I call pstorage function in timer handler function

    void Freq_timer_handler(void * p_context)
    {
    	  app_beacon_scanner_stop();
    	  uint32_t                retval;
    		retval = pstorage_init();
    		   
    		param.block_size  = 16;                   
    		param.block_count = 10;                   
    		param.cb          = example_cb_handler;
    			
    		retval = pstorage_register(&param, &master_handle);
    		
    		
    		   //Get block identifiers
    		   retval = pstorage_block_identifier_get(&master_handle, 0, &block_0_handle);
    			
    		   retval = pstorage_clear(&block_0_handle, 16);                   //Clear first registered page. A pstorage_clear command must operate within a single page
    		   retval = pstorage_wait_handle = block_0_handle.block_id;            //Specify which pstorage handle to wait for 
    		   retval = pstorage_wait_flag = 1; 
    		   retval = pstorage_store(&block_0_handle, source_data_1, 16, 0);     //Write to flash	
          			 
    			 for (int i = 0; i < 16;i++)
    			 {
    				  source_data_2[i] += 1;
    			 }
    			 retval = pstorage_block_identifier_get(&master_handle, 0, &block_0_handle);
    			 retval = pstorage_load(temp, &block_0_handle, 16, 0);
    

    ........

Children
No Data
Related