<?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>BLE ANT App Timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/14310/ble-ant-app-timer</link><description>Hi all, 
 I have a firmware in which I want to use BLE and ANT communication (with Softdevice S310) to send and receive commands from other Nordic devices or smartphones. I also have 64 RGB LEDs WS2812 which have a specific communication protocol and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Jun 2016 09:32:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/14310/ble-ant-app-timer" /><item><title>RE: BLE ANT App Timer</title><link>https://devzone.nordicsemi.com/thread/54591?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2016 09:32:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86319de1-d33f-42be-b9a6-2fe8f641ba6a</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;It depends on wether or not is would stop other more important things from executing. If you do not have important stuff in main() or in other interrupt handler, it should be fine. But yes, it is a good rule of thumb to keep interrupt handlers short :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE ANT App Timer</title><link>https://devzone.nordicsemi.com/thread/54592?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2016 22:57:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9189ca01-2e53-4e1a-bf13-c0b38dc426d8</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;I have 64 LEDs to update. That makes 64 * 32us = 2048us
Is that ok to update the LEDs in the timer event handler itself?
I thought that it was good practice to have few instructions executed in a short amount of time in the event handlers in general...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE ANT App Timer</title><link>https://devzone.nordicsemi.com/thread/54590?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2016 08:14:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1702e111-1e82-403f-b035-1a094f3820e3</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;With BLE only, one can schedule things between connection events using the app_timer. With ANT trown into the mix, things will be a bit more complex. What you can try is the following: Create an app_timer which updates the led at the frequency you want (probably 20+ Hz?). In the timer event handler, check if it is &amp;quot;safe&amp;quot; to update the leds. You can check this by checking if the radio is being used soon with the radio event notifications. In this way, you will lose some led updates here and there, but it might be few enough that you won&amp;#39;t notice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE ANT App Timer</title><link>https://devzone.nordicsemi.com/thread/54589?ContentTypeID=1</link><pubDate>Mon, 06 Jun 2016 17:37:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7cb937a-9082-49ed-b286-76cbe1996db4</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;Thanks for the answer, Anders. Yes I have seen this code for the WS2812 and I am using it already. My concern is that I need to update the colors of the LEDs more often than just at the single moment where the radio events are finished. I was then thinking of updating the LEDs in the main loop based on the status of a flag set in the radio callback as defined here:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void myradio_callback_handler(bool radio_active)
{
	if (radio_active) // radio going active
	{
		bNeoShow = false;
	}
	else if (radio_active == false) //radio inactive
    {
		bNeoShow = true;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE ANT App Timer</title><link>https://devzone.nordicsemi.com/thread/54588?ContentTypeID=1</link><pubDate>Mon, 06 Jun 2016 13:37:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b7b153b-3b03-4ed2-b56c-a372efffd53c</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;In the &lt;a href="https://www.google.no/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0ahUKEwillcmct5PNAhXGdCwKHUWSDssQFggbMAA&amp;amp;url=https%3A%2F%2Fwww.adafruit.com%2Fdatasheets%2FWS2812.pdf&amp;amp;usg=AFQjCNE0mCwTl-i_ufj5D6mhem8YrRJmhg&amp;amp;sig2=wJal9M3S5S29WjashRZ0QA&amp;amp;bvm=bv.123664746,d.bGg&amp;amp;cad=rja"&gt;WS2812 data sheet&lt;/a&gt;, we can see that the shortest pulse we must send is 0.35 uS. The lowest time we can count with the app_timer is 32 uS, because it uses the 32khz RTC timer.&lt;/p&gt;
&lt;p&gt;You can find a library for using ws2812 with the nRF51 on &lt;a href="https://github.com/lavallc/nrf51-neopixel"&gt;this&lt;/a&gt; github page. This implementation bit-bangs the protocol using assembly. This is the most common way of interfacing to the ws2812 (afaik).
They also included a note about using the lib with a softdevice. As you suggested, it uses the radio notification API.&lt;/p&gt;
&lt;p&gt;Sending data to one led will take about 32 uS. Since it is so fast, it is ok to just do a blocking implementation (bit banging). Just do it right after the radio events are finished.&lt;/p&gt;
&lt;p&gt;The timeslot API could also be used, but you would not be guaranteed a slot 100% periodically.&lt;/p&gt;
&lt;p&gt;-Anders&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>