<?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 event handler problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66497/timer-event-handler-problem</link><description>Dear all, 
 I just writing a little piece of code (no softdevice, using sdk 17.00), that in theory toggle a led based on 2 compare (CC[0] and CC[1]). 
 
 The strange thing is that, if the 2 compare are pretty high (1 second or more) there is no problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 30 Sep 2020 12:00:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66497/timer-event-handler-problem" /><item><title>RE: Timer event handler problem</title><link>https://devzone.nordicsemi.com/thread/272282?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 12:00:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd84641-c2b8-4af3-ab2a-c174ba5417bd</guid><dc:creator>Elia_pell</dc:creator><description>&lt;p&gt;Ok, I manage to print the log on debug terminal and in fact now it&amp;#39;s working as expected (the log are the same as you): so thank you! From now on, I will use NRF_LOG_INFO instead of printf.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Elia&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer event handler problem</title><link>https://devzone.nordicsemi.com/thread/272240?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 10:36:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c42472b8-895e-4acd-866a-994385d40263</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you running the code on a nRF52840 DK? It is outputting the log on the Debug Terminal when I run it. Which version of Segger Embedded Studio are you using? I tested this on v4.50.&lt;/p&gt;
&lt;p&gt;If not, try using Segger J-Link RTT Viewer directly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer event handler problem</title><link>https://devzone.nordicsemi.com/thread/272239?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 10:33:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b32dc014-e598-496b-a5f9-45acf99083f4</guid><dc:creator>Elia_pell</dc:creator><description>&lt;p&gt;Dear Jorgen,&lt;/p&gt;
&lt;p&gt;Unfortunately nothing is print on the Debug terminal: why??&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elia&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer event handler problem</title><link>https://devzone.nordicsemi.com/thread/272210?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 09:10:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:786ce012-1c0b-420f-b8bc-f61bbda16b3c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi Elia,&lt;/p&gt;
[quote user=""]1) Why isn&amp;#39;t the timer stopped instantly? (but it needs two cycles)[/quote]
&lt;p&gt;Since you are handling the stopping of the timer in the interrupt handler, the CPU requires some time to wakeup and call the interrupt handler when the interrupt is generated. Since you have configured the timer with only 8-bits width, it will overflow when the internal counter reaches 255. This will happen after ~8 ms, which means that the CPU should have plenty of time to handle the interrupt before this if nothing it blocking the handling of the interrupt. I tested your code on my DK, but I&amp;#39;m not able to reproduce any of the issues you are listing. This is the output from my run:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: ON: 322

&amp;lt;info&amp;gt; app: OFF: 1282&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure how you have implemented the printf statements, but could these slow down the application and cause this behavior?&lt;/p&gt;
[quote user=""]2) Why are the timestamps not correct? (I expected that OFF - ON = 960)[/quote]
&lt;p&gt;As you can see above, I&amp;#39;m seeing a delta of exactly 960 in my run. Again, I believe that something must be slowing down your code, causing this.&lt;/p&gt;
&lt;p&gt;I have attached my test-project. Can you have a run with this and see what values it is giving you?&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4578.timer_5F00_cc.zip"&gt;devzone.nordicsemi.com/.../4578.timer_5F00_cc.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It is possible to configure PPI to trigger the STOP and CAPTURE tasks in hardware when the events are generated. This would prevent you from relaying on constant interrupt latency for giving correct results.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>