<?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>TIMERS IN NRF5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74591/timers-in-nrf5340</link><description>HI , 
 My environment: 
 
 nrf connect sdk 
 nrf5340 dk 
 segger studio ide. 
 
 
 could you please provide me timer example code for nrf5340 board. 
 Thanks &amp;amp; Regards, 
 Srinivas.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Apr 2021 22:34:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74591/timers-in-nrf5340" /><item><title>RE: TIMERS IN NRF5340</title><link>https://devzone.nordicsemi.com/thread/307570?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 22:34:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fa76699-1ee1-4756-abf8-1a4179899fd2</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;RTC peripheral&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The k_timer_start() will actually use the&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf5340%2Frtc.html&amp;amp;cp=3_0_0_6_27"&gt; RTC peripheral&lt;/a&gt;, in the following manner:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/include/kernel.h#L1380"&gt;k_timer_start()&lt;/a&gt;&amp;nbsp;| zephyr/include/kernel.h
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/kernel/timer.c#L109"&gt;z_impl_k_timer_start()&lt;/a&gt;&amp;nbsp;| &lt;em&gt;zephyr/kernel/timer.c&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/kernel/timeout.c#L87"&gt;z_add_timeout()&lt;/a&gt;&amp;nbsp;| &lt;em&gt;zephyr/kernel/timeout.c&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/drivers/timer/nrf_rtc_timer.c#L342"&gt;z_clock_set_timeout()&lt;/a&gt;&amp;nbsp;|&amp;nbsp;drivers/timer/nrf_rtc_timer.c&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;Uses functions from&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/v1.5.1/nrfx/hal/nrf_rtc.h"&gt;nrf_rtc.h&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By default&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/kconfig/CONFIG_NRF_RTC_TIMER.html"&gt;CONFIG_NRF_RTC_TIMER&lt;/a&gt;&amp;nbsp;will be equal to y (check &amp;lt;sample&amp;gt;/build/zephyr/.config), which will &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/drivers/timer/CMakeLists.txt#L10"&gt;make it use the RTC&lt;/a&gt;. I think you can use a systick timer by enabling&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/kconfig/CONFIG_CORTEX_M_SYSTICK.html#cmdoption-arg-CONFIG_CORTEX_M_SYSTICK"&gt;CONFIG_CORTEX_M_SYSTICK&lt;/a&gt;. However, RTC is probably the best choice between these:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/21067/nrf52-use-systick-or-rtc/82317#82317"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/21067/nrf52-use-systick-or-rtc/82317#82317&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Timer peripheral&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/include/drivers/counter.h"&gt;counter.h API&lt;/a&gt;&amp;nbsp;enables you to use both the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf5340%2Ftimer.html&amp;amp;cp=3_0_0_6_34"&gt;TIMER peripheral&lt;/a&gt;&amp;nbsp;as well as the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf5340%2Frtc.html&amp;amp;cp=3_0_0_6_27"&gt;RTC peripheral&lt;/a&gt;, by setting&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/drivers/counter/CMakeLists.txt#L10"&gt;CONFIG_COUNTER_NRF_TIMER&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1/drivers/counter/CMakeLists.txt#L11"&gt;CONFIG_COUNTER_NRF_RTC&lt;/a&gt;&amp;nbsp;in the prj.conf.&lt;/p&gt;
&lt;p&gt;Check out the sample &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v2.4.99-ncs1/samples/drivers/counter/alarm"&gt;zephyr/samples/drivers/counter/alarm&lt;/a&gt; to see how to use the counter API.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re wondering if you should use the TIMER or the RTC, I would recommend you to read the following:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/12731/clocks-timers-rtc-why/48338#48338"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/12731/clocks-timers-rtc-why/48338#48338&lt;/a&gt;. It was written a long time ago for a different chip and SDK, but should be somewhat relevant still&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TIMERS IN NRF5340</title><link>https://devzone.nordicsemi.com/thread/307510?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 13:32:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26b331b0-a169-4e7c-b688-8d927e034e2f</guid><dc:creator>SRINI</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;It seems to be zephyr&amp;nbsp; based kernel timers API (soft timers) in the ADC code. can I get hardware based timer example code?&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Srinivas.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TIMERS IN NRF5340</title><link>https://devzone.nordicsemi.com/thread/307442?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 11:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1d0af8a-6693-4ad9-8367-4ee4053108cc</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Take a look at the NCS tutorial, section&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-4-0#h185sjwm5882m1bcimiad82dnf4kcy0b"&gt;3.5 Add the ADC peripheral&lt;/a&gt;, which provides a sample using a timer. It may be useful to complete&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-4-0#h22sjwht26buofm6h31gzxdos802c0"&gt;3.2 Set it up&lt;/a&gt;,&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-4-0#h178sjwm57p2ic3iadcdo6t2kdckuol"&gt;3.3 Build and flash it&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-4-0#h183sjwm5829mbs21y3111ulj6et5ph1"&gt;3.4 Modify the device tree&lt;/a&gt;&amp;nbsp;first.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>