<?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>WRITE AND READ SAADC DATA WITH FDS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49048/write-and-read-saadc-data-with-fds</link><description>nrf52832 S132 v6.1.1 
 i want to write saadc data in flash, so i call &amp;quot;write_to_flash&amp;quot; function in &amp;quot;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)&amp;quot; 
 
 sizeof(data_array3) is 240, so every record in flash is 60 words, 
 virtual page is 3; 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Oct 2019 07:55:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49048/write-and-read-saadc-data-with-fds" /><item><title>RE: WRITE AND READ SAADC DATA WITH FDS</title><link>https://devzone.nordicsemi.com/thread/216991?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 07:55:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51244069-a50d-458d-83a7-9066943152a7</guid><dc:creator>1730143</dc:creator><description>&lt;p&gt;thanlks a lot&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: WRITE AND READ SAADC DATA WITH FDS</title><link>https://devzone.nordicsemi.com/thread/195327?ContentTypeID=1</link><pubDate>Fri, 28 Jun 2019 10:22:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:434d4d37-6669-4b96-ab8c-d2823b14b720</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Using flash for buffering data is generally not a good idea, because of the relatively slow speed compared to RAM and because it wears down (10.000 write/erase cycles).&lt;/p&gt;
&lt;p&gt;Flash is a good idea for persistent data, that is data that must survive a device reset (turning it off and on again.)&lt;/p&gt;
&lt;p&gt;You should still be able to store data in a buffer in RAM, if you use the 64 kB RAM variant of the nRF52832. Especially so if you move to the nRF52840 with 256 kB RAM.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: WRITE AND READ SAADC DATA WITH FDS</title><link>https://devzone.nordicsemi.com/thread/195240?ContentTypeID=1</link><pubDate>Fri, 28 Jun 2019 02:07:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10d6c25a-698c-4bd6-b472-86d8dd4edb1e</guid><dc:creator>1730143</dc:creator><description>&lt;p&gt;thanks for your reply&lt;/p&gt;
&lt;p&gt;my m_dummy_data structure:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint8_t data_array3[240]={0};
static fds_record_t const m_dummy_record =
{
    .file_id           = CONFIG_FILE,
    .key               = CONFIG_REC_KEY,
    .data.p_data       = &amp;amp;data_array3,
    /* The length of a record is always expressed in 4-byte units (words)*/
    .data.length_words = (sizeof(data_array3)+3) / sizeof(uint32_t),
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;Queueing a flash operation on every saadc measurement is not necessarily a good idea, as flash operations are probably much slower than the rate of measurements.&amp;nbsp;&amp;quot; &amp;quot;You may also get data races where a record is written to flash while you are half-way updating the record structure.&amp;quot; i think you are rigtht.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i set &amp;quot;uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer, frequency_sel)&amp;quot;&amp;nbsp; frequecy_sel 1ms, the saadc rate may be much higher than fds operation.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In my instance, i can get event that&amp;nbsp;&amp;nbsp;tells the operation is finished successfully and&amp;nbsp;&amp;quot;no space in flash&amp;quot; when flash is full, i run gc when flash is full.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1561687270248v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;the reason why i use fds to store saadc data is that i can&amp;#39;t get high throughout(&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44854/notification-nrf52832-data-rate" rel="noopener noreferrer" target="_blank"&gt;my another question&lt;/a&gt;), so i want to store data when data rate is high ,then stop saadc and send it slowly to master. ram size is much smaller than flash, even the falsh size is not enough with such high data rate. so it is not a good idea to store hight rate&amp;nbsp; adc data in flash? i will try to increase&amp;nbsp;&amp;nbsp;&amp;quot;frequecy_sel&amp;nbsp;&amp;quot; to low down data rate.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;thanks again!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: WRITE AND READ SAADC DATA WITH FDS</title><link>https://devzone.nordicsemi.com/thread/195203?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2019 15:19:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f44c5a4d-a93f-4f83-aee1-08b6e44bb945</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There are a few missing parts here, for instance how you populate the m_dummy_record data structure that you write to FDS using fds_record_write() in write_to_flash()? Note also that FDS operations are asynchronous, and they are not finished before you get an event that tells you either that the operation is finished successfully or that an error occured.&lt;/p&gt;
&lt;p&gt;Queueing a flash operation on every saadc measurement is not necessarily a good idea, as flash operations are probably much slower than the rate of measurements. That in turn may lead to problems. If you store the data to be written in the same static memory location for all queued writes, and have multiple writes in the queue, then you may get into a situation where the same data is written multiple times. You may also get data races where a record is written to flash while you are half-way updating the record structure.&lt;/p&gt;
&lt;p&gt;Depending on the use case, it may be a much better idea to buffer data in RAM instead of going via flash. Especially if the data rate is such that you have to write a record every few minutes. Also, you should only do garbage collection when flash is full (or near full). The flash is limited to 10k write/erase cycles, which means if you continuously write and erase flash you will quickly wear down the flash (and it will not work any more.)&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>