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

problem with pstorage store operation.

Hi, I use pstorage to allocate 32bytes of memory with 2 block, means each block having 16 bytes, when I write 16byte data into block_0 portion, I am not able to go to the call back handler for write operation, but I receive NRF_SUCCESS from the pstorage_store() function, and when I read from the block_0 portion I read Junk. the sample piece of code is given below.

SDK : 6.1.0 , S110 version 7.1.0

pstorage_load() function calls handler but whereas pstorage_store() doesn't but returns a NRF_SUCCESS status . pstorage_init() and pstorage_register() function returns NRF_SUCCESS.

pstorage_handle_t 	handle, block_0_handle, block_1_handle;
pstorage_module_param_t param;
    unsigned char G_Sensor_Str[16], Dest_G_data[16];

    M_Status = pstorage_init();
if (M_Status == NRF_SUCCESS) { nrf_gpio_pin_clear(P_TEST_LED_0); }

param.block_size  = 16;                   //Select block size of 16 bytes
param.block_count = 2;                   //Select 2 blocks, total of 2*16 bytes
param.cb          = example_cb_handler; //Set the pstorage callback handler

M_Status = pstorage_register(&param, &handle);
if (M_Status == NRF_SUCCESS) { nrf_gpio_pin_clear(P_TEST_LED_1); }

pstorage_block_identifier_get(&handle, 0, &block_0_handle);
pstorage_block_identifier_get(&handle, 0, &block_1_handle);

pstorage_clear(&block_0_handle,32);                       //Clear 32 bytes
    memset(G_Sensor_Str, 'E', 16);
M_Status = pstorage_store(&block_0_handle, G_Sensor_Str, 16, 0);     
while(M_Status);			       		  //wait until store operation is finished.

pstorage_load(Dest_G_data, &block_0_handle, 16, 0);
Parents Reply Children
No Data
Related