<?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>How to create a timer by using nRF connect SDK on nRF52840dk board</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68370/how-to-create-a-timer-by-using-nrf-connect-sdk-on-nrf52840dk-board</link><description>Hi nRF support team, By using the nRF Connect SDK, I am trying to create a timer, which I can use for incrementing a counter by 1 for each second on a timer interrupt handler. Can you please share how to create a timer and any sample code? Regards, K</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Nov 2020 14:58:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68370/how-to-create-a-timer-by-using-nrf-connect-sdk-on-nrf52840dk-board" /><item><title>RE: How to create a timer by using nRF connect SDK on nRF52840dk board</title><link>https://devzone.nordicsemi.com/thread/280156?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 14:58:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee8574ca-8e32-4639-ad3d-38f2cfca7024</guid><dc:creator>Kalyan Agepati</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;Thanks for the quick response and suggestion.&lt;/p&gt;
&lt;p&gt;I have adjusted &amp;quot;0&amp;quot; to &amp;quot;2&amp;quot;, but still I am not getting any nRF timer event.&lt;/p&gt;
&lt;p&gt;I have tried Zephyr kernel timers (based on the 32k RTC) and it is working as expected and I am receiving timer event handler. Thanks for the suggestion.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Kalyan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a timer by using nRF connect SDK on nRF52840dk board</title><link>https://devzone.nordicsemi.com/thread/280061?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 09:43:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a891fa8c-90fe-4171-8658-eba408075898</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In order to use interrupts in your application, you have to enable it using the OS wrapper functions, like done here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/peripheral/radio_test/src/radio_test.c#L577-L581"&gt;https://github.com/nrfconnect/sdk-nrf/blob/master/samples/peripheral/radio_test/src/radio_test.c#L577-L581&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For your case, you need to adjust &amp;quot;0&amp;quot; to &amp;quot;2&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that you can also create a kernel timer (based on the 32k RTC):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/timing/timers.html#using-a-timer-expiry-function"&gt;https://docs.zephyrproject.org/latest/reference/kernel/timing/timers.html#using-a-timer-expiry-function&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a timer by using nRF connect SDK on nRF52840dk board</title><link>https://devzone.nordicsemi.com/thread/280023?ContentTypeID=1</link><pubDate>Sun, 15 Nov 2020 19:25:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02c53fb5-27e8-4632-bda1-c5d4116af20e</guid><dc:creator>Kalyan Agepati</dc:creator><description>&lt;p&gt;Hi nRF support team,&lt;/p&gt;
&lt;p&gt;For your reference, I have attached code and output log. The issue is, not receiving nrf timer event handler? Please let me know if anything I am missing here?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;main.c::&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;static volatile uint32_t m_counter = 0; // System time in microseconds&lt;/p&gt;
&lt;p&gt;//static const nrfx_timer_t m_timer = NRFX_TIMER_INSTANCE(2);&lt;br /&gt;static const nrfx_timer_t m_timer = NRFX_TIMER_INSTANCE(4);&lt;br /&gt;&lt;br /&gt;void timer_handler(nrf_timer_event_t event_type, void *p_context) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printk(&amp;quot;timer_handler()....\n&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_counter += 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void timer_init(void) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrfx_err_t err;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_cfg.mode = NRF_TIMER_MODE_TIMER;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //timer_cfg.mode = NRF_TIMER_MODE_COUNTER;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err = nrfx_timer_init(&amp;amp;m_timer, &amp;amp;timer_cfg, timer_handler);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printk(&amp;quot;nrfx_timer_init() return value [0x%x]\n&amp;quot;, err);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t ticks = nrfx_timer_ms_to_ticks(&amp;amp;m_timer, 1000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printk(&amp;quot;ticks[%d]\n&amp;quot;, ticks);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrfx_timer_extended_compare(&amp;amp;m_timer, NRF_TIMER_CC_CHANNEL0, ticks,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrfx_timer_enable(&amp;amp;m_timer);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void main(void)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_init();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* Implement notification. At the moment there is no suitable way&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; * of starting delayed work so we do it here&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while (1)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printk(&amp;quot;m_counter value [%d]\n&amp;quot;, m_counter);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Referesh actual data every two minutes&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;k_sleep(K_SECONDS(2));&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Output::&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;*** Booting Zephyr OS build v2.3.0-rc1-ncs1-2410-g7d20f2ebf259&amp;nbsp; ***&lt;br /&gt;nrfx_timer_init() return value [0xbad0000]&lt;br /&gt;ticks[16000000]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;br /&gt;m_counter value [0]&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>