<?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>Using FDS to save a Struct (Structure) and also reading it</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55153/using-fds-to-save-a-struct-structure-and-also-reading-it</link><description>I am trying to save and read a structure using FDS, how do I go about it? 
 I have the structure: 
 
 My custom function for saving is: 
 
 I call the function using below: 
 
 But I get error 0x03 at: 
 
 Suggestions would be greatly appreciated</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Dec 2019 12:41:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55153/using-fds-to-save-a-struct-structure-and-also-reading-it" /><item><title>RE: Using FDS to save a Struct (Structure) and also reading it</title><link>https://devzone.nordicsemi.com/thread/223325?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 12:41:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02094335-2c99-43eb-8eff-fd173ab8e9d6</guid><dc:creator>Ameer Usman</dc:creator><description>&lt;p&gt;This worked perfectly:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;__ALIGN(4) beacon_packet_struct   beacon_flags;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also the error of 0x02 I had was solved by putting a &lt;strong&gt;nrf_delay_ms(300);&lt;/strong&gt; right after &lt;strong&gt;fds_init();&lt;/strong&gt; and thus it did not crash on the subsequent write.&lt;/p&gt;
&lt;p&gt;Kudos Vidar! :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using FDS to save a Struct (Structure) and also reading it</title><link>https://devzone.nordicsemi.com/thread/223324?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 12:39:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27d7a3ef-287b-4263-8157-4359a71bba38</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="Ameer Usman"]Also is my flash saving procedure (especially the length_words variable) ok?[/quote]
&lt;p&gt;&amp;nbsp;Yes, the length calculation looks ok. the +3 should ensure that the length is always rounded up.&lt;/p&gt;
[quote user="Ameer Usman"]As for reading I have done the following, can you verify if this is the right way to do it?[/quote]
&lt;p&gt;&amp;nbsp;It looks correct to me, but you need to test it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using FDS to save a Struct (Structure) and also reading it</title><link>https://devzone.nordicsemi.com/thread/223317?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 12:24:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91b19fc8-ce2d-418e-b336-209ea38d705f</guid><dc:creator>Ameer Usman</dc:creator><description>&lt;p&gt;Thanks Vidar but it worked once but upon performing erase and then again running it, it is giving error 0x02 on write function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for sticking&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using FDS to save a Struct (Structure) and also reading it</title><link>https://devzone.nordicsemi.com/thread/223306?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 12:03:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da924013-eb83-400f-a1c5-c77c90c15a7c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The error code indicates that your .p_data pointer is not aligned to a 4-byte boundary as is required when flash writes. Try to define your &amp;#39;beacon_flags&amp;#39; variable as shown below and see if you get the same error:&lt;/p&gt;
&lt;p&gt;__ALIGN(4) beacon_packet_struct&amp;nbsp; &amp;nbsp;beacon_flags;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>