<?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>Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83724/multithreading-on-nrf9160</link><description>Hello Nordic gang. I&amp;#39;m reading sensor data on the nrf9160DK, the sensors have a fifo with 96 entries. If I can&amp;#39;t read the sensors fast enough, the fifo overflows and I get data loss. The sampling rate is 4000 SPS and the sample size is 64bit. Therefore</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Jan 2022 15:36:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83724/multithreading-on-nrf9160" /><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/349609?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 15:36:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:619bbd28-83d3-48af-8e44-780bc0699d3d</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Nice, I will check it out, thanks Edvin :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/349583?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 14:43:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd70254a-b9fd-4fd2-9c02-d3d461a9c2cf</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. Yes, you can use one thread to read and one thread to write. I am not familiar with the nRF91, but look at how the NCS\nrf\samples\bluetooth\peripheral_uart uses one thread to read UART and another to send UART data over Bluetooth LE.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348749?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2022 14:27:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f057369d-abe1-48ed-89a9-598fe72a9ab2</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;The only way it detects the SD-card is if it is formatted with the official sd-cart-formatter. Windows wont do. In that formatter you can&amp;#39;t set your preferred cluster size but it detects the size of the sd-card and sets cluster size according to that. My card has a cluster size of 32kB and not 512 bytes(64 entries * 8 bytes per entry = 512 bytes). If I can&amp;#39;t work around this, is it possible to write code such that when the writing operation is busy, I simultaneously read the sensor and store it in a variable until the fs_write function is done and then write that data to the card? &lt;br /&gt;&lt;br /&gt;Thanks Edvin, I really appreciate your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348688?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2022 12:16:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:171fcfc1-c548-4aa0-ab93-6eeed14ebb5f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;A bit outside my field, but have you tried to reformat the SD card to see if changing the &amp;quot;allocation unit size&amp;quot; changes the behavior?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348508?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 13:07:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:236c0259-bcef-4d7a-b91e-0f1790f4220a</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;I call fs_write all the time, and every 64 samples fs_write() takes longer than usual. That is why I&amp;#39;m thinking of allocation of new memory space. I&amp;#39;m using a 32gb sd-card because that is what I had on hand but a 2gb would do just fine. I ordered one (hard to find a 2gb sd-card in modern times haha) to see if maybe that speeds things up a bit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348463?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 10:52:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33f75c36-02fd-49d5-8140-be7f040cdfdf</guid><dc:creator>Edvin</dc:creator><description>[quote user="nWre"]there is a delay using fs_write[/quote]
&lt;p&gt;Is the delay caused by the call to fs_write(), or do you call fs_write all the time, and every 64 samples fs_write() takes longer than usual?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348303?ContentTypeID=1</link><pubDate>Tue, 18 Jan 2022 13:49:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6289b9a3-d755-4bc4-adf8-3e4b7726779d</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi again Edvin! Sure, I drew a picture that might explain it better.&lt;br /&gt;Is there an example of running threads with prio and datatransfer like you described? &lt;br /&gt;As shown in the picture, at multiple of 4096 bits, there is a delay using fs_write. I&amp;#39;m thinking this might be because of the page/cluster size of the fileformat fat32 but I&amp;#39;m not sure. I formatted it with 32kB cluster size so it might rather be a different problem entirely.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/500x763/__key/communityserver-discussions-components-files/4/3731.Untitled.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348299?ContentTypeID=1</link><pubDate>Tue, 18 Jan 2022 13:34:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:875bcb8f-bf6e-4f7c-a9e8-470e0eab60e0</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I don&amp;#39;t think I understood that part about resizing. Can you please explain what you mean by that?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="nWre"]The question of multithreading is still relevant for me though as when data is recorded and saved, I then need to send this via FTP so server. During the transmission of this, I still need the sensors to be active and ready to record in a triggering event, that is, the system can&amp;#39;t be occupied fully if you understand what I mean.[/quote]
&lt;p&gt;What triggers the reading from the sensor? Is it triggered from the sensor, or from your software?&lt;/p&gt;
&lt;p&gt;Either way you want the thread handling the sensor&amp;#39;s interrupts to be running at a high priority. The transmission of the data to the server is will happen on the modem core, which will not be interrupted.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348091?ContentTypeID=1</link><pubDate>Mon, 17 Jan 2022 14:36:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e790f4fc-1e90-40b7-bf0f-6c201eaf0559</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi Edvin! I&amp;#39;m running SPI at the highest possible speed. I thought about larger chunks but wont there still be a resizing problem once the page size is reached? Writing 8 bytes at a time is fast enough, it is just the page resizing that slows it down. I will of course try this and get back to you. &lt;br /&gt;&lt;br /&gt;The question of multithreading is still relevant for me though as when data is recorded and saved, I then need to send this via FTP so server. During the transmission of this, I still need the sensors to be active and ready to record in a triggering event, that is, the system can&amp;#39;t be occupied fully if you understand what I mean. &lt;br /&gt;&lt;br /&gt;Thanks for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multithreading on nrf9160</title><link>https://devzone.nordicsemi.com/thread/348090?ContentTypeID=1</link><pubDate>Mon, 17 Jan 2022 14:33:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8901345-1111-4f54-b95f-50adc309bb82</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello nWre,&lt;/p&gt;
&lt;p&gt;If I understand the issue correctly, you are poking the limit of the sd card communication, because of the rate of which the data is coming from your sensor, right?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you considered/tried to either:&lt;/p&gt;
&lt;p&gt;Increase the SPI speed (I assume that the SD card reader uses SPI or TWI (I2C)? Is it possible to increase the clock speed of that peripheral?&lt;/p&gt;
&lt;p&gt;Buffer up more data before you write to the SD card. Larger chunks means less overhead with the communication with the SD card.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Perhaps one of the two can get you below the threshold, so that you can keep up with the sensor data?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>