<?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>current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12502/current-time-gets-0-after-connectiong-with-bluetooth</link><description>hi,
i am using ble_uart example to take time when data arrives and time when data being sent over bluetooth.
when i prints the time without connecting to bluetooth. then the time gives a value.
but after connecting with bluetooth it gives 0. i dont</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Apr 2018 09:09:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12502/current-time-gets-0-after-connectiong-with-bluetooth" /><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/129295?ContentTypeID=1</link><pubDate>Mon, 23 Apr 2018 09:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:563928d2-9582-4240-8ac7-d1224efe469f</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I cannot understand anything else other than the RTC1 is not running. Could you explicitly start the RTC and then immediately read its values:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	case BSP_EVENT_KEY_0:
	                    RTC1-&amp;gt;TASKS_START = 1;
	                    nrf_ms_delay(5);
						rtc_value = NRF_RTC1-&amp;gt;COUNTER; 
						NRF_LOG_INFO(&amp;quot;RTC value: %d \n\r&amp;quot;, rtc_value);
						nrf_ms_delay(5);
						rtc_value = NRF_RTC1-&amp;gt;COUNTER; 
						NRF_LOG_INFO(&amp;quot;RTC value 2: %d \n\r&amp;quot;, rtc_value);
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/128855?ContentTypeID=1</link><pubDate>Wed, 18 Apr 2018 15:05:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:835ed68f-a2d2-4769-b9b9-7e778b8176da</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;Unfortunately, this does not change anything.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/128803?ContentTypeID=1</link><pubDate>Wed, 18 Apr 2018 12:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90fa3181-e25b-4024-bdaf-b896a25d7a77</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;In the button push event, could you do two read-outs of the&amp;nbsp; RTC1 value, to check if the RTC1 value changes. It should give an indication of whether RTC1 is running or not.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	case BSP_EVENT_KEY_0:
						rtc_value = NRF_RTC1-&amp;gt;COUNTER; 
						NRF_LOG_INFO(&amp;quot;RTC value: %d \n\r&amp;quot;, rtc_value);
						nrf_ms_delay(5);
						rtc_value = NRF_RTC1-&amp;gt;COUNTER; 
						NRF_LOG_INFO(&amp;quot;RTC value 2: %d \n\r&amp;quot;, rtc_value);
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/128754?ContentTypeID=1</link><pubDate>Wed, 18 Apr 2018 09:17:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:122f1991-dfab-4548-ba9c-eaabd12ba818</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;Thanks for taking the effort to test it. I really appreciate your help so far. &lt;/p&gt;
&lt;p&gt;I also tried it on the ble_app_hrs (I use nRF51-DK, SDK 11, S130 v2.0) with the push of button 2 printing the COUNTER register. I also get non-zero and seemingly correct values both in advertising and connected state.&lt;/p&gt;
&lt;p&gt;But when I try the same on my peripheral example (so also with a push on button 2 printing the COUNTER register) I still get strange results in connected state. In advertising state it prints fine, but in connected state it starts printing the same values after each other:&lt;/p&gt;
&lt;p&gt;839 &lt;br /&gt;167 &lt;br /&gt;906 &lt;br /&gt;167 &lt;br /&gt;167 &lt;br /&gt;167 &lt;br /&gt;167 &lt;br /&gt;167 &lt;br /&gt;167 &lt;br /&gt;167 &lt;br /&gt;168 &lt;br /&gt;167&lt;br /&gt;&amp;nbsp;...&lt;/p&gt;
&lt;p&gt;So a bit strange. I used to print the values in the radio off event of the radio notification handler and there the register values still give 0 in the connected state. I guess it will have something to do with my example specifically but I wouldn&amp;#39;t know what I do wrong. It&amp;#39;s just a application that reads out an accelerometer with I2C and sends the measured data over a BLE connection. Could it have something to do with the TWI operation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/128646?ContentTypeID=1</link><pubDate>Tue, 17 Apr 2018 13:36:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8657611f-288e-4c3e-a41a-1dfe4482e476</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I just tested again reading the counter value, and it works fine to read NRF_RTC1-COUNTER, both when the&amp;nbsp;device is advertising, and when in connected state (nRF51-DK, SDK 12.3.0, S132 v.2.0.1, ble_app_hrs)&lt;pre class="ui-code" data-mode="c_cpp"&gt;	case BSP_EVENT_KEY_0:
						rtc_value = NRF_RTC1-&amp;gt;COUNTER; //NRF_RTC1-&amp;gt;CC[0];
						NRF_LOG_INFO(&amp;quot;RTC value: %d \n\r&amp;quot;, rtc_value);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Another option is to do the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_RTC1-&amp;gt;CC[0] = NRF_RTC1-&amp;gt;COUNTER;
rtc_value = NRF_RTC1-&amp;gt;CC[0];&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127813?ContentTypeID=1</link><pubDate>Wed, 11 Apr 2018 11:20:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cde89386-8987-4e8b-a8c0-3545e7b524ab</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;App_timer is used in my application. And I&amp;#39;m using nRF51 so unfortunately, I can only use RTC1. But I don&amp;#39;t need the timer I defined, I just need to get the value of the Counter register of RTC1 at any moment I want. And I don&amp;#39;t understand why that gives me 0 when the SoftDevice and thus my application, is in a BLE connection, which is the same issue as the people above I believe.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I &amp;quot;fixed&amp;quot; the register giving 0 by starting a self defined timer when in a connection, but I don&amp;#39;t understand why I would need to do that? If app_timer is used, I presume that RTC1 is thus active and used and thus the Counter register should be giving me correct values without needing me to start a self defined timer, no?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127789?ContentTypeID=1</link><pubDate>Wed, 11 Apr 2018 10:29:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aff48412-e261-4032-9931-bc2b613c43c1</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;Is app_timer used somewhere in your application? I so, your timer and app_timer will share RTC1. In that case, could you try to use RTC2 instead for your timer?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127744?ContentTypeID=1</link><pubDate>Wed, 11 Apr 2018 07:51:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d48e02b5-e247-44dd-8ae1-20bf2163d5da</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;Unfortunately, that doesn&amp;#39;t seem to be working. If I explicitly start RTC1 using NRF_RTC1-&amp;gt;TASKS_START = 1, and don&amp;#39;t run the empty, self defined timer anymore, I again get 0 on every request for the RTC1 Counter register&amp;#39;s value. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127739?ContentTypeID=1</link><pubDate>Wed, 11 Apr 2018 07:26:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d20b637-0019-44e7-b220-a50f95b109d0</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I see. I had forgotten what this thread was about.&lt;/p&gt;
&lt;p&gt;It should not be necessary to to use the app_timer module, what is necessary is to explicitly start RTC1. You should get the same result if you do the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_RTC1-&amp;gt;TASKS_START = 1;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127549?ContentTypeID=1</link><pubDate>Tue, 10 Apr 2018 08:16:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cf02721-d92e-4541-90ab-a25503c199bb</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;Well, I have the same problem as the two people above. If use the SoftDevice but don&amp;#39;t connect (so just stay advertising), &lt;em&gt;app_timer_cnt_get&lt;/em&gt; gives me the current value of the RTC1 Counter register, as expected. But when the advertiser connects with a central and thus becomes a peripheral, &lt;em&gt;app_timer_cnt_get&lt;/em&gt; gives 0 constantly&lt;code&gt;&lt;em&gt;.&lt;/em&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;app_timer &lt;/em&gt;module is used in my application and initializes RTC1 with a prescaler of 0. Above you stated &amp;quot;When you are using app_timer with the softdevice, could you try to explicitly start app_timer using app_timer_start(..), and see if that changes anything?&amp;quot;. How can you start the app_timer in general with that method &lt;em&gt;(app_timer_start(..)&amp;nbsp;&lt;/em&gt;) ? &lt;em&gt;&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;em&gt;&lt;/em&gt;From what I see in the infocenter, I can only use this method to start self defined timers that use RTC1 underneath. When I start such a timer (with an empty handler and repeated (not single mode) )&amp;nbsp; using &lt;em&gt;app_timer_start, &lt;/em&gt;after a connection is established, &lt;em&gt;app_timer_cnt_get&lt;/em&gt; doesn&amp;#39;t give me 0 anymore but gives me seemingly correct counter values. But I don&amp;#39;t understand why I need to start an unused timer to get this effect? &lt;code&gt;&lt;em&gt;&lt;/em&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127534?ContentTypeID=1</link><pubDate>Tue, 10 Apr 2018 07:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa498a55-6f9c-4ffb-a27c-172f90fa114c</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand what you mean, could you elaborate a little?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127465?ContentTypeID=1</link><pubDate>Mon, 09 Apr 2018 14:16:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a2d04f3-7912-4f43-b184-e3cfab468afd</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;I&amp;#39;m not using RTC0, I&amp;#39;m using RTC1. I don&amp;#39;t understand why I need to run a timer, just to ensure the RTC1 is run as well so that I can read the Counter register when needed. I solved it like that now, just by using a repeatable timer that I don&amp;#39;t do anything else with. But I still don&amp;#39;t understand why I would need that. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127459?ContentTypeID=1</link><pubDate>Mon, 09 Apr 2018 14:02:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d22584f-2fb5-422c-b874-b1f122e5735f</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;As stated in the &amp;quot;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.sds%2Fdita%2Fsoftdevices%2Fs130%2Fsd_resource_reqs%2Fhw_block_interrupt_vector.html&amp;amp;cp=2_3_1_0_6_0"&gt;Hardware peripheral&lt;/a&gt;&amp;quot; chapter in the Sotfdevice Specification, RTC0 is &amp;quot;blocked&amp;quot; when using the softdevice:&lt;/p&gt;
&lt;p&gt;Blocked:&amp;nbsp;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The hardware peripheral is used by the SoftDevice&lt;span&gt;&amp;nbsp;and is outside the application sandbox&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;The application has no access.&amp;nbsp;&lt;/span&gt;Interrupts from blocked peripherals are forwarded to the SoftDevice by the MBR and are not available to the application, even inside a Radio Timeslot API timeslot.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/127182?ContentTypeID=1</link><pubDate>Fri, 06 Apr 2018 09:31:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76eb7331-8599-4132-86c1-708a547b4883</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;How can you do that if your not using a self-made timer? I have the same issue but I don&amp;#39;t understand why you would have to start a new timer just to read out the RTC1-&amp;gt;Counter register? &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/47403?ContentTypeID=1</link><pubDate>Mon, 01 Aug 2016 19:28:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d5b7e04-434f-4092-8088-0056dd2b339a</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;&amp;quot;current_time&amp;quot; is defined the following way: &lt;code&gt;static uint32_t current_time&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;In the code snippet above, current_time gets its value from app_timer_cnt_get(..). For how app_timer works, it may be useful to take a look at the app timer documentation, it can be found &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Flib_timer.html&amp;amp;cp=6_0_0_3_27"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/47402?ContentTypeID=1</link><pubDate>Sun, 17 Jul 2016 13:19:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:445af629-a7ce-46c9-8eab-eba019aa9de4</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;could you show how to declare &lt;code&gt;current_time&lt;/code&gt;, and let it be the RTC count? thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/47405?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2016 05:56:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e5e5830-5693-459a-8b49-a737409736ed</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The app_timer module uses RTC1 and the softdevice uses RTC0, the softdevice should therefore not have any effect of the RTC1 value.&lt;/p&gt;
&lt;p&gt;When you are using app_timer with the softdevice, could you try to explicitly start app_timer using app_timer_start(..), and see if that changes anything?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/47404?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2016 09:11:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfa5db06-0cf4-423e-8fb5-0f4967dc8522</guid><dc:creator>energy</dc:creator><description>&lt;p&gt;Hi,
I have the same problem using sdk 9.0 and an application based on ble_app_uart.
Timer init is identical as ble_app_uart (APP_TIMER_INIT called with same APP_TIMER_.. values)&lt;/p&gt;
&lt;p&gt;Call to app_timer_cnt_get() returns a correct value (around 33k tics/per sec) when the softdevice is not connected and returns 0 when softdevice is connected. If I disconect the app_timer_cnt_get() works again&lt;/p&gt;
&lt;p&gt;How did you fix this problem ? Thanks&lt;/p&gt;
&lt;p&gt;Edit: does app_timer_cnt_get requires to start a timer with timer_start to work ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: current time gets 0 after connectiong with bluetooth</title><link>https://devzone.nordicsemi.com/thread/47401?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 11:51:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b72bdb86-b4f8-44bc-b6a2-e2f53e444d51</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;How do you initialize the timer?&lt;/p&gt;
&lt;p&gt;What is the prescaler set to?&lt;/p&gt;
&lt;p&gt;Do you manage the RTC &amp;quot;on your own&amp;quot; somewhere?&lt;/p&gt;
&lt;p&gt;To get the current value of the timer, I would recommend you to use the function &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fgroup__app__timer.html&amp;amp;cp=4_0_0_6_8_22_16&amp;amp;anchor=ga497a82797a160ef7f13f8aa26c637018"&gt;app_timer_cnt_get(..)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When I test a very similar code of yours here, it works:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            index++;
						
						if(index%3 == 0)
            {
                //count++;
                err_code = app_timer_cnt_get(&amp;amp;current_time);
		        APP_ERROR_CHECK(err_code);
								
								
		        err_code  = app_timer_cnt_get(&amp;amp;current_time); 
			   nrf_delay_ms(20);
			   err_code  = app_timer_cnt_get(&amp;amp;previous_time);
			   err_code  = app_timer_cnt_get(&amp;amp;duration_time);
			   err_code = app_timer_cnt_diff_compute(current_time,previous_time,&amp;amp;duration_time);
			   APP_ERROR_CHECK(err_code);
			   printf(&amp;quot;current:%d\tprevious:%d\tduration:%d\n\r&amp;quot;,current_time,previous_time,duration_time);
								
								
			   previous_time = current_time;
               
            }   
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>