<?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>Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38008/issue-with-timer-in-soft-device-s132</link><description>Dear Sir, 
 
 I am new to Nordic. This is my first query. It is related to running Timer with softdevice. I am using TIMER1 ( as const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(1);) 
 I could run the application in the &amp;lt;SDK&amp;gt;\examples\peripheral</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Sep 2018 04:41:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38008/issue-with-timer-in-soft-device-s132" /><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146866?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 04:41:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20f304b7-cf8a-4488-a705-eb7792da3921</guid><dc:creator>GK</dc:creator><description>&lt;p&gt;Hi, Currently I am trying to do the same with app_timer.Thank you for your suggestion&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146777?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 12:42:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:570e8bfc-a46b-4402-abf8-85024e20e1c6</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If the timeout handler is called 20-30 times per second there is definitely something wrong. Can you check the value of&amp;nbsp;&lt;span&gt;time_ticks passed to&amp;nbsp;nrf_drv_timer_extended_compare? Yes, if the config is set to 0, the timer should run at 16 MHz.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would still recommend that you look into using app_timer for controlling your application. You can find a tutorial &lt;a href="https://devzone.nordicsemi.com/tutorials/b/software-development-kit/posts/application-timer-tutorial"&gt;here&lt;/a&gt;. Plese note that there are &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_timer.html?cp=4_0_1_3_48_1#lib_timer_migration"&gt;some changes in newer SDKs&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146658?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 08:15:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f49bbefb-17b3-49f5-a464-62efa65d7959</guid><dc:creator>GK</dc:creator><description>&lt;p&gt;Yes..I have modified and forgot to revert it.&amp;nbsp; Sorry for that.But it is not coming for every 10 seconds also.It is too fast .&lt;/p&gt;
&lt;p&gt;Here the define statement is as follows&lt;/p&gt;
&lt;p&gt;#define TIMER_DEFAULT_CONFIG_FREQUENCY 0. I think it is set to &amp;#39;&amp;nbsp;NRF_TIMER_FREQ_16MHz&amp;#39;.right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146630?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 07:30:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e758fb05-86cf-4e5e-a250-3ffdeae0ae4c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;&lt;span&gt;If you run a timer at highest frequency (16 MHz), the timer will overflow after ~4.47 minutes. What have you set the frequency (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__drv__timer__config.html#gaa138454695a2059d48da2e247c620007"&gt;TIMER_DEFAULT_CONFIG_FREQUENCY&lt;/a&gt;) to in your sdk_config.h file? It also looks like you set time_ms to 10 seconds in your code, not 1 minute as you claim.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146566?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 15:50:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8af674b4-7f75-4bbf-9937-8e9ad62d7fc5</guid><dc:creator>GK</dc:creator><description>&lt;p&gt;Dear&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen Holmefjord&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much for your reply.&lt;/p&gt;
&lt;p&gt;I am using SDK version 15.0.0_a53641a.&amp;nbsp; Currently the time out handler is calling around&amp;nbsp; 20 -30 times per second(it (the print statement) goes too fast&amp;nbsp; so exact value I could not get ).The timer I want to use for 5 minute. Just for checking I used&amp;nbsp; the value 1 minute. &lt;strong&gt;Actually I want to wake up the system every 5 minute and start advertising for say 1 minute. Then&amp;nbsp; go to sleep. Again after 5 minute start advertising...go on like this. So I am planning to call advertiing_start() function inside the handler, so that it will get called every 5 minute.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I am copying the code( excluded the part not related to timer).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Please correct me if I am wrong somewhere.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;#include &amp;quot;nrf.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_drv_timer.h&amp;quot;&lt;br /&gt;#include &amp;quot;bsp.h&amp;quot;&lt;br /&gt;#include &amp;quot;app_error.h&amp;quot;&lt;/p&gt;
&lt;p&gt;const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(1);&lt;/p&gt;
&lt;p&gt;.......(some functions are there)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)&lt;br /&gt;{&lt;br /&gt; static uint32_t i;&lt;br /&gt; uint32_t led_to_invert = 2;//((i++) % LEDS_NUMBER);&lt;/p&gt;
&lt;p&gt;switch (event_type)&lt;br /&gt; {&lt;br /&gt; case NRF_TIMER_EVENT_COMPARE1:&lt;br /&gt;NRF_LOG_INFO(&amp;quot;Inside handler&amp;quot;);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;default:&lt;br /&gt; //Do nothing.&lt;br /&gt; break;&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;............................&lt;/p&gt;
&lt;p&gt;...............................&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;int main(void)&lt;br /&gt;{&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; bool erase_bonds;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; uint32_t time_ms = 1000*10; //Time(in miliseconds) between consecutive compare events.//GK added&lt;br /&gt; uint32_t err_code = NRF_SUCCESS;//GK added&lt;br /&gt; uint32_t time_ticks; //GK added&lt;/p&gt;
&lt;p&gt;// Initialize.&lt;br /&gt; log_init();&lt;br /&gt; timers_init();&lt;br /&gt;leds_init(&amp;amp;erase_bonds);//GK modified&lt;br /&gt; power_management_init();&lt;br /&gt; ble_stack_init();&lt;br /&gt; gap_params_init();&lt;br /&gt; gatt_init();&lt;br /&gt; advertising_init();&lt;br /&gt; services_init();&lt;br /&gt;conn_params_init();&lt;br /&gt; peer_manager_init();&lt;/p&gt;
&lt;p&gt;// Start execution.&lt;br /&gt; NRF_LOG_INFO(&amp;quot;Sieva example started.&amp;quot;);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; application_timers_start();&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; advertising_start(erase_bonds);&lt;/p&gt;
&lt;p&gt;nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;//GK added for timer&lt;br /&gt; err_code = nrf_drv_timer_init(&amp;amp;TIMER_LED, &amp;amp;timer_cfg, timer_led_event_handler);//GK added&amp;nbsp; for timer&lt;br /&gt; APP_ERROR_CHECK(err_code);//GK added for timer&lt;/p&gt;
&lt;p&gt;time_ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;TIMER_LED, time_ms);&amp;nbsp;&lt;span&gt;//GK added for timer&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;nrf_drv_timer_extended_compare(&lt;br /&gt; &amp;amp;TIMER_LED, NRF_TIMER_CC_CHANNEL1, time_ticks, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);//GK added for timer&lt;/p&gt;
&lt;p&gt;nrf_drv_timer_enable(&amp;amp;TIMER_LED);//GK added for timer&lt;/p&gt;
&lt;p&gt;// Enter main loop.&lt;br /&gt; for (;;)&lt;br /&gt; {&lt;br /&gt; idle_state_handle();&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146529?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 13:18:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c6a5bc1-c77c-40c6-895d-4201ee170233</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;yes, you are right. &amp;nbsp;I was thinking about RTC timer. &amp;nbsp;The High Freq timer is mostly use for the radio and the RTC is mostly used as app timer. &amp;nbsp;That is what I was thinking about. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146522?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 13:05:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:485ccd34-f1da-4dc6-819b-eeb52e5ce79a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/hnhoan"&gt;Nguyen Hoan Hoang&lt;/a&gt;: TIMER1 is not used by the softdevice or SDK. Application timer library use RTC1 as its timer source.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/gk"&gt;GK&lt;/a&gt;: How did you configure the timer? How often is the timeout handler called? Which SDK version are you using? I would not recommend using a timer for 1 minute intervals, app_timer or RTC would be a better alternative, as it runs on lower frequency clock source, giving you lower accuracy but also much lower current consumption.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with TIMER in soft device S132</title><link>https://devzone.nordicsemi.com/thread/146501?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 12:29:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb812796-4dec-4ca8-a3d1-a508a586c8d7</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;timer0 &amp;amp; 1 are used by softdevice and SDK. &amp;nbsp;2 way to use timer with softdevice.&lt;/p&gt;
&lt;p&gt;1) use app_timer (timer1)&lt;/p&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;p&gt;2) use timer2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>