<?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>Best way to do high frequency writes to SPI - using ticker?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8349/best-way-to-do-high-frequency-writes-to-spi---using-ticker</link><description>I&amp;#39;m using the mbed platform and have been battling hard faults as I try to find the best way to write with high frequency to SPI to update a series of LEDs while still allowing for intermittent data to come in on BLE to change settings for the LEDs, </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Jul 2015 17:28:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8349/best-way-to-do-high-frequency-writes-to-spi---using-ticker" /><item><title>RE: Best way to do high frequency writes to SPI - using ticker?</title><link>https://devzone.nordicsemi.com/thread/30242?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2015 17:28:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5113d9b0-b2da-4a70-81ed-65651331a223</guid><dc:creator>dmf3030</dc:creator><description>&lt;p&gt;The actual LEDupdate function that the ticker is pointing to is very quick, just moving some data around in an array.  The SPI write where I actually push that data to a strip of LEDs happens in the LEDs.update(); call which is in the main loop.  Basically the ticker updates the LED data then sets a flag so that the next time you hit the main loop the function to push that data to the SPI is called.&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t had a chance to remove the SPI writes that are in the main loop, but I will do that now to see if I can still get a hardfault there.  I also need to figure out why adding a characteristic to my service causes the a fault where the code was stable before.  I&amp;#39;ll report back with anything I find.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to do high frequency writes to SPI - using ticker?</title><link>https://devzone.nordicsemi.com/thread/30241?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2015 14:20:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38935794-5eb7-4199-8228-43dab71461c4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@dmf3030: How long did it take in your ticker call back (LEDupdate) ?  If it&amp;#39;s a long process, you may consider doing it in the main loop. The ticker call back only set a flag.&lt;/p&gt;
&lt;p&gt;Have you tried to remove the SPI code in the call back and check if hardfault still occurs ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to do high frequency writes to SPI - using ticker?</title><link>https://devzone.nordicsemi.com/thread/30240?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2015 12:06:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17f8958f-e2b5-41fe-bcee-9af224247307</guid><dc:creator>dmf3030</dc:creator><description>&lt;p&gt;Forgot to answer your final question, my connection interval is the default setup for mbed&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN        = 0x0020; // 40ms
static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN_NONCON = 0x00A0; // 200ms
static const unsigned GAP_ADV_PARAMS_INTERVAL_MAX        = 0x4000; // 20480ms
static const unsigned GAP_ADV_PARAMS_TIMEOUT_MAX         = 0x3FFF; // 163830ms
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to do high frequency writes to SPI - using ticker?</title><link>https://devzone.nordicsemi.com/thread/30239?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2015 11:37:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7533230f-7c1c-43f5-9c8d-8822ced9caa1</guid><dc:creator>dmf3030</dc:creator><description>&lt;p&gt;Sorry I understand the mbed API is its own world, I have posted this to the mbed forum but I&amp;#39;ve found the nordic forum to be much more responsive and I&amp;#39;ve found good info here so I decided to give it a shot.  I will add the actual code I&amp;#39;m using to the main question for clarity and I will also try your two suggestions of just doing a delay instead of SPI and of doing nothing in the onDataWritten function.&lt;/p&gt;
&lt;p&gt;I guess the primary question still persists, is this the correct way to approach writing to the SPI repeatedly at a relatively short interval, (8-10ms at the shortest)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to do high frequency writes to SPI - using ticker?</title><link>https://devzone.nordicsemi.com/thread/30238?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2015 09:34:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:184a6929-27a7-4229-acfb-b0e4c348d9e0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@dmf3030: We don&amp;#39;t have much experience with mbed so I would suggest you to also create a thread on mbed forum to seek for help.&lt;/p&gt;
&lt;p&gt;It sounds strange to me that a short interval tiker ( I assume you were using a timer to do the tick) would cause a hardfault.&lt;/p&gt;
&lt;p&gt;What if you try:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;don&amp;#39;t do any thing SPI related in the ticker handler, but just a simple delay in the ticker handler?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;don&amp;#39;t do anything in onDataWrittenCallback()&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What was your short ticker interval and what was the long one ? Also what was your connection interval ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>