<?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>Get timer count without stopping timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59088/get-timer-count-without-stopping-timer</link><description>Hello all! 
 
 How can I get the current count of a timer without stopping it? 
 
 Right now I&amp;#39;m doing like this: 
 _timer_base-&amp;gt;TASKS_CAPTURE[channel] = 1; uint32_t counter = _timer_base-&amp;gt;CC[channel]; 
 return counter; 
 
 That returns the expected value</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 17 Mar 2020 07:52:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59088/get-timer-count-without-stopping-timer" /><item><title>RE: Get timer count without stopping timer</title><link>https://devzone.nordicsemi.com/thread/240161?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2020 07:52:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d520cdce-43bf-45a8-bd6d-d7115f93d986</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Yes. That is probably the reason why it stopped. You can use another CC to capture the register.&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get timer count without stopping timer</title><link>https://devzone.nordicsemi.com/thread/240064?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 14:52:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee11b917-1e4d-42d9-a172-99fdd5949a6c</guid><dc:creator>Jose Cazarin</dc:creator><description>&lt;p&gt;Thank you!&lt;br /&gt;So, I kept searching in the forum and I found this topic:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/2173/capture-timer-value"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/2173/capture-timer-value&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Check Nikita&amp;#39;s answer:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;You are already using CC[0] register for COMPARE0 event interrupt, so if you want to read current timer counter value you need to trigger CAPTURE task for another channel i.e.: NRF_TIMER2-&amp;gt;TASKS_CAPTURE[1] = 1; u_sec = (NRF_TIMER2-&amp;gt;CC[1]);&lt;/span&gt;&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;This is exactly my situation. I&amp;#39;m using channel 0 (EVENT_COMPARE[0]) to generate the interruption. And it worked for me to just use another channel for capturing the timer count, like this:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;_timer_base-&amp;gt;TASKS_CAPTURE[1] = 1;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;uint32_t counter = _timer_base-&amp;gt;CC[1];&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Since Nikita&amp;#39;s answer if from 6 years ago, I just want to confirm: is that still valid?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And another question: is there any status register that I can read so I know if the timer is running or not? I just realized I need that information too&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you so much!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get timer count without stopping timer</title><link>https://devzone.nordicsemi.com/thread/239922?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 09:40:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da21ac7e-66f7-4c1e-b166-85266f43de70</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;By default, if the timer is set up correctly, taking one capture shouldn&amp;#39;t stop the timer from running. I don&amp;#39;t know how you set up the timer, or what timer you used.&lt;/p&gt;
&lt;p&gt;Please have a look at the attached main.c file which is a slightly modified ble_app_hrs main.c file.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-54a5e138a39e407a9ad245d4d1e7a351/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please have a look at&amp;nbsp;test_timer_timeout_handler(). In addition, I added an app_timer instance with a timeout handler:&amp;nbsp;test_timer_timeout_handler(), which will capture the NRF_TIMER3, and print the capture register. Please note that the app_timer and the timer that I capture are two different TIMER instances, working independently.&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>