<?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>Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5552/timer-is-not-accurate-with-softdevice</link><description>Hi nordics! 
 First of all, thanks for answering my questions before. 
 
 Now, I want to generate a clock(48 pulses) with 200us width. 
 However, sometimes the width of pulse(clock) is not accurate. 
 
 **yellow line is the clock line. 
 (Maybe</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Feb 2015 21:54:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5552/timer-is-not-accurate-with-softdevice" /><item><title>RE: Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/thread/19431?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 21:54:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01f019e4-152e-4823-9a76-797265c681fd</guid><dc:creator>Krzysztof Loska</dc:creator><description>&lt;p&gt;You are right. My previous comment was false (so I deleted it to not confuse people). I read the problem description too quick before leaving the work on Friday evening :)...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/thread/19432?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 16:31:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afc57818-96bd-482d-bb59-2f3b65b874e5</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand how that could work. How are you going to get 96(assuming a gpiote toggle task) first channel compares before you get one second channel compare?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/thread/19433?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 15:26:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a42a3445-87bd-41c3-9152-c39ac8dd1c0e</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I suspect the root of this delay in clock is that the CPU is not available to process the TIMER2 interrupt. This is because the softdevice blocks the CPU up to 6 ms during a radio event. The thing you can do is to avoid using the CPU for the generation of the clock. Do that by using PPI channels instead. That way you connect the TIMER2 event directly with GPIOTE task. You can see how that is done in the gpiote_example in the nRF51 SDK.&lt;/p&gt;
&lt;p&gt;You would have to use sd_* function to configure and set the PPI channels after you initialize the softdevice. You can see an example of that in the PWM library on Github, namely in the &lt;a href="https://github.com/NordicSemiconductor/nrf51-pwm-library/blob/master/nrf_pwm.c"&gt;nrf_pwm.c&lt;/a&gt; file line 57&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/thread/19430?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 08:53:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:295dbfe1-f0b4-4a26-84dd-2798db4a5921</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;Your comment does not help at all with understanding what you want to do.
However, it seems to me that if you use a timer/counter to generate the clocks pulses by using a GPIO task linked to.timer compare events, you can probably also link the timer event(or another event from the same timer, i.e. another compare) to an increment task on another hardware counter timer, which would count up to 48 and then generate a compare event that would link to a task that stops the first timer. Not entirely sure if this would work, I&amp;#39;d try it if I didn&amp;#39;t have work to do - it&amp;#39;s exactly the sort of thing I find fascinating.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/thread/19429?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 00:34:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f279c62c-1bd3-46ba-a525-1288d7e3823b</guid><dc:creator>Kyu</dc:creator><description>&lt;p&gt;Actually, It is not I2C, but it is similar to i2c.
To be more specific SDA doesn&amp;#39;t make signals according to the SCL.&lt;/p&gt;
&lt;p&gt;So I should make accurate SCL pulse.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer is not accurate with softDevice.</title><link>https://devzone.nordicsemi.com/thread/19428?ContentTypeID=1</link><pubDate>Thu, 12 Feb 2015 14:08:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f84ecf31-4729-4107-8882-261700800ad1</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;Firstly, I believe:
NRF_TIMER2-&amp;gt;CC[0] = 100;
should be:
NRF_TIMER2-&amp;gt;CC[0] = 99;
as the counter counts from zero.
Aside from that, I think that when the soft device is running, the timer interrupts may be delayed substantially, as the BLE stuff has to take priority.
It is fairly easy to use events and tasks to generate rock-steady clock pulses(as the hardware handles everything), the only tricky thing will be how to stop at 48 pulses when the interrupts can get delayed by as much as your trace suggests.
I notice you have referred to SCL in the code, so I assume this is being used in some capacity relating to I2C? If so, are you ignoring the SDA signal? Perhaps some better explanation of what you are trying to achieve will result in more useful answers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>