<?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>SD Write Problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25971/sd-write-problem</link><description>Hi Everyone, 
 I am trying to record data from ADC to a SD card every 500ms using nrf52832.
I am following the fatfs example. Before I had a problem whereby every approximately
10s I would lose a few samples from the ADC as shown by the figure below</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Nov 2017 13:45:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25971/sd-write-problem" /><item><title>RE: SD Write Problem</title><link>https://devzone.nordicsemi.com/thread/102319?ContentTypeID=1</link><pubDate>Wed, 15 Nov 2017 13:45:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9956ecbf-4850-4550-9f21-4aa796b6e3aa</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you seeing any write errors reported in sdWrite function? I would recommend that you check all error codes related to writing to SD card and check with a debugger that the missing samples are actually sampled and tried written to the card. It would also be interesting if you could measure the current on the nRF chip only, to see if the excessive current is drawn by the chip or the card.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD Write Problem</title><link>https://devzone.nordicsemi.com/thread/102318?ContentTypeID=1</link><pubDate>Mon, 13 Nov 2017 21:13:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecc43689-ab35-47fc-9c98-59900a1c3ccf</guid><dc:creator>bryanhsieh</dc:creator><description>&lt;p&gt;Hi Jorgen sorry for the late response but I have added the relevant code.
I mainly debug in RTT viewer, I haven&amp;#39;t tried debugging in Keil for this project yet.
To measure the current, I am using a DC power analyzer attached to the input of the DC boost converter, so the current is increased for the whole circuit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD Write Problem</title><link>https://devzone.nordicsemi.com/thread/102317?ContentTypeID=1</link><pubDate>Mon, 06 Nov 2017 15:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9d41ffd-5312-4ba2-afda-1037b2c8429e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Could you post the code showing how you write to SD card? Is the increased current only for nRF chip, or for whole circuit? Have you tried to debug to see if the chip is stuck on some blocking function when the current is increased, preventing sleep and blocking processing of events?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD Write Problem</title><link>https://devzone.nordicsemi.com/thread/102316?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 15:23:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5658b67-11b8-4c6b-96da-2803fc73d306</guid><dc:creator>bryanhsieh</dc:creator><description>&lt;p&gt;I think there are not being written to the SD card as if you look at the first graph, there is a gap(white line) at every 200 samples (10 seconds). And looking at the power consumption with a DC power analyzer(figure 2), I found that these gaps correspond to the sudden increase in write current of the SD card from normal spikes of around 20ms to a prolonged one of around 200ms.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD Write Problem</title><link>https://devzone.nordicsemi.com/thread/102315?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 15:13:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6782d79-a74d-4c75-8e33-7bc447c9caf7</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;What do you mean when you say you lose samples? Are they not written to SD card, or not sampled? Are you seeing any errors when writing to the card?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD Write Problem</title><link>https://devzone.nordicsemi.com/thread/102314?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 02:41:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:408cb386-66aa-46ab-9f2f-f3d8d8e640cc</guid><dc:creator>rct42</dc:creator><description>&lt;p&gt;Writing to SD cards is often more difficult than people expect. Although I haven&amp;#39;t used fatfs for a while (I&amp;#39;ve moved to Keil&amp;#39;s FlashFS), the general principle is &amp;quot;write&amp;quot; your samples into a large as possible ring buffer stored in RAM. I presume your ADC samples are done in an ISR? Meanwhile in your main loop, continuously check this ring buffer. If there is a complete block (usually 512 bytes) to write out, call f_write to write the data out to the SD card.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>