hi,
i have tried to write data into flash memory, but i can not, i can read the data from memory.
i had followed your instruction as this link
infocenter.nordicsemi.com/index.jsp
and some other solutions like this following thread
as per above thread i used 30ms delay aslo.
please any one help me,
note:-
i had used RTC1 interrupt with every 5ms for real time clock to generate current date and time.
This my source code,
uint32_t mem_clear(int block_num, int page_num)
{
uint32_t nReturnValue;
int i=0;
nReturnValue = pstorage_block_identifier_get(&block_id,block_num,&block_0_id);
if (nReturnValue != 0)
{
return INTIAL_GET_TYPE_WRONG_3;
}
for (i=0;i<page_num;i++)
{
nReturnValue = pstorage_clear(&block_0_id,1024);
block_0_id.block_id += 1024;
nrf_delay_ms(30);
if (nReturnValue != 0)
{
return INTIAL_GET_TYPE_WRONG_4;
}
}
}
uint32_t read_from_mem(unsigned char *des,int block_num, int size, int offset)
{
uint32_t nReturnValue;
nReturnValue = pstorage_block_identifier_get(&block_id,block_num,&block_0_id);
if(nReturnValue != 0)
{
return GET_SYSTEM_PASSWORD_BLOCK_ID_ERR;
}
nReturnValue = pstorage_load(&des[0],&block_0_id,size,offset);
if (nReturnValue !=0 )
{
return GET_SYSTEM_PASSWORD_FAIL;
}
nrf_delay_us(500);
return nReturnValue;
}
uint32_t write_from_mem(unsigned char *src,int block_num, int size, int offset)
{
uint32_t nReturnValue;
nReturnValue = pstorage_block_identifier_get(&block_id,block_num,&block_0_id);
if(nReturnValue != 0)
{
return false;
}
nReturnValue = pstorage_store(&block_0_id,&src[0],size,offset);
nrf_delay_ms(30);
if (nReturnValue !=0 )
{
return false;
}
return nReturnValue;
}
static void example_cb_handler(pstorage_handle_t * handle,uint8_t op_code, uint32_t result, uint8_t * p_data, uint32_t data_len)
{
if(handle->block_id == pstorage_wait_handle) { pstorage_wait_flag = 0; } //If we are waiting for this callback, clear the wait flag.
switch(op_code)
{
case PSTORAGE_LOAD_OP_CODE:
if (result == NRF_SUCCESS)
{
nrf_delay_ms(1);
}
else
{
nrf_delay_ms(1);
}
break;
case PSTORAGE_STORE_OP_CODE:
if (result == NRF_SUCCESS)
{
nrf_delay_ms(1);
}
else
{
nrf_delay_ms(1);
}
break;
case PSTORAGE_UPDATE_OP_CODE:
if (result == NRF_SUCCESS)
{
nrf_delay_ms(1);
}
else
{
nrf_delay_ms(1);
}
break;
case PSTORAGE_CLEAR_OP_CODE:
if (result == NRF_SUCCESS)
{
nrf_delay_ms(1);
}
else
{
nrf_delay_ms(1);
}
break;
case PSTORAGE_ERROR_OP_CODE:
nrf_delay_ms(1);
break;
}
}