<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>data saved different to data read</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4784/data-saved-different-to-data-read</link><description>Hi,
I want to save settings in the memory.
In my case, the softdevice is enabled, there is no ble advertising.
I use pstorage functions.
Problem: I stored 0x12, 0x23, 0x45,0x67. But I read 0xFF, 0xFF, 0xFF, 0xFF. 
 Initialization 
 void init_app_data_flash_manager</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 May 2016 07:26:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4784/data-saved-different-to-data-read" /><item><title>RE: data saved different to data read</title><link>https://devzone.nordicsemi.com/thread/16950?ContentTypeID=1</link><pubDate>Tue, 10 May 2016 07:26:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0353eb1d-083a-4643-997f-91eeb2c9df96</guid><dc:creator>koustubhavachat</dc:creator><description>&lt;p&gt;where is declaration  of &amp;quot;NRF_CLOCK_LFCLKSRC_XTAL_20_PPM&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data saved different to data read</title><link>https://devzone.nordicsemi.com/thread/16949?ContentTypeID=1</link><pubDate>Fri, 12 Dec 2014 14:13:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0638a54c-5fdc-4fda-b738-f7edb74a297b</guid><dc:creator>ting&amp;#178;</dc:creator><description>&lt;p&gt;Thank you for your help!
I did not work, because I forgot this part:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void sys_evt_dispatch(uint32_t sys_evt)
{
    pstorage_sys_event_handler(sys_evt);
}

void body_ble_stack_init(void) {
	uint32_t err_code;
	// Initialize the SoftDevice handler module.
	SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM , false);
	err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
	
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data saved different to data read</title><link>https://devzone.nordicsemi.com/thread/16948?ContentTypeID=1</link><pubDate>Thu, 11 Dec 2014 14:31:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cfd03c4-b719-48da-88c4-76c9b513af47</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Hi, if you are calling the read immediately after the write, the 0xFF return is to be expected. The update operation takes time, but the pstorage update function is non-blocking. So, the update was not complete when you read the memory back. This thread shows one solution to the problem &lt;a href="https://devzone.nordicsemi.com/question/19218/wait-on-nrf_evt_flash_operation_success-to-continue/"&gt;Wait for event&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It isn&amp;#39;t elegant but it is effective. I do not know why the callback wasn&amp;#39;t called, its hard to tell without seeing all of the code invoking these functions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data saved different to data read</title><link>https://devzone.nordicsemi.com/thread/16947?ContentTypeID=1</link><pubDate>Thu, 11 Dec 2014 08:28:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70762d9e-736f-4773-9d5e-c7981223f113</guid><dc:creator>ting&amp;#178;</dc:creator><description>&lt;p&gt;Firstly,   I called the functions &lt;em&gt;read_setting_from_flash()&lt;/em&gt; just after &lt;em&gt;save_settings_to_flash()&lt;/em&gt;.
It gave me the previous result. Then I tried with a callback function like below:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void app_data_flash_manager_cb_handler(pstorage_handle_t * handle, uint8_t op_code, uint32_t result, uint8_t * p_data, uint32_t data_len)
{ 
	switch(op_code)
	{
		case PSTORAGE_STORE_OP_CODE:
			if (result == NRF_SUCCESS)
			{
				 UART_TXT(&amp;quot;Storage successful..\r\n\0&amp;quot;);
				 
			// Store operation successful.
			}
			else
			{
				 UART_TXT(&amp;quot;Storage failed..\r\n\0&amp;quot;);
			// Store operation failed.
			}
		case PSTORAGE_ERROR_OP_CODE:
			if (result == NRF_SUCCESS)
			{
			// Operation successful.
			}
			else
			{
			// Error! Operation failed.
			}
		case PSTORAGE_LOAD_OP_CODE:
			if (result == NRF_SUCCESS)
			{
			// Store operation successful.
			}
			else
			{
			// Store operation failed.
			}
			// Source memory can now be reused or freed.
			break;
		case PSTORAGE_UPDATE_OP_CODE:
			if (result == NRF_SUCCESS)
			{
			// Update operation successful.
			}
			else
			{
			// Update operation failed.
			}
			break;
		case PSTORAGE_CLEAR_OP_CODE:
			if (result == NRF_SUCCESS)
			{
				 UART_TXT(&amp;quot;Storage cleared..\r\n\0&amp;quot;);
				 save_settings_to_flash();
			}
			else
			{
				 UART_TXT(&amp;quot;j&amp;#39;ai pas reussi à effacer..\r\n\0&amp;quot;);
			}
			break;
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But the function is never called....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data saved different to data read</title><link>https://devzone.nordicsemi.com/thread/16946?ContentTypeID=1</link><pubDate>Wed, 10 Dec 2014 18:46:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25892087-81d7-480b-a668-9b80a520511a</guid><dc:creator>John</dc:creator><description>&lt;p&gt;The 0xFF values are typically erased NVRAM. Best guess without seeing how your actually invoke your two functions is that you are calling your readings_from_flash function before the pstorage_update operation has completed. Are you waiting for the NRF_EVT_FLASH_OPERATION_SUCCESS event before calling your readings_from_flash function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>