<?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>Timer - nRF52833</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66217/timer---nrf52833</link><description>Hello everyone, 
 I&amp;#39;m a fresher of programming nRF52833. I&amp;#39;m working with Timer and I have some questions like this: 
 
 Can I use several timer in an application? I mean I want to use 4 timer for 4 GPIOTE. Is that possible to do?? 
 How can I measure</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Sep 2020 10:08:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66217/timer---nrf52833" /><item><title>RE: Timer - nRF52833</title><link>https://devzone.nordicsemi.com/thread/271284?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 10:08:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b85b87ff-366e-4f3c-9a59-95197ac31e88</guid><dc:creator>Nguyen Trong Tuan</dc:creator><description>&lt;p&gt;thanks for your reference and your reply. I&amp;#39;m very appreciate about it. Thanks for your support&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer - nRF52833</title><link>https://devzone.nordicsemi.com/thread/271275?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 09:40:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c998a66-208f-4008-9fc7-c9dd17a25468</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;1. That depends on how you are interacting with the timer. If you are writing directly to the registers, you can use NRF_TIMER1-&amp;gt;/&lt;span&gt;NRF_TIMER2-&amp;gt; and so on. If you are using the timer driver, you can pass 1/2/3/4 to the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__drv__timer.html#ga62a2c86c94dea6fb4f1bee649a98922f"&gt;NRF_DRV_TIMER_INSTANCE&lt;/a&gt;() macro when defining&amp;nbsp;the timer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. I created an example for something similar some time ago, see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/23267/how-to-measure-two-wave-delay/91490#91490"&gt;this post&lt;/a&gt;. If you are not using pin inputs to generate the events, you can remove the&amp;nbsp;gpiote_init() function. Then you should replace the following events in ppi_init() with the events you want to measure time between:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t gpiote_evt_addr_1          = nrf_drv_gpiote_in_event_addr_get(PIN_IN_1);
uint32_t gpiote_evt_addr_2          = nrf_drv_gpiote_in_event_addr_get(PIN_IN_2);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nRF52 series ICs also has a fork feature for PPI, allowing you to trigger two separate tasks from a single event over the same PPI channel. You can replace the following:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel_2);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel_3);
APP_ERROR_CHECK(err_code);

uint32_t timer_stop_task_addr       = nrf_drv_timer_task_address_get(&amp;amp;m_timer, NRF_TIMER_TASK_STOP);
uint32_t timer_compare_task_addr    = nrf_drv_timer_task_address_get(&amp;amp;m_timer, NRF_TIMER_TASK_CAPTURE0);

err_code = nrf_drv_ppi_channel_assign(ppi_channel_2, gpiote_evt_addr_2, timer_compare_task_addr);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_assign(ppi_channel_3, gpiote_evt_addr_2, timer_stop_task_addr);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_enable(ppi_channel_2);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_enable(ppi_channel_3);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;With this, if you want to save a PPI channel:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel_2);
APP_ERROR_CHECK(err_code);

uint32_t timer_stop_task_addr       = nrf_drv_timer_task_address_get(&amp;amp;m_timer, NRF_TIMER_TASK_STOP);
uint32_t timer_compare_task_addr    = nrf_drv_timer_task_address_get(&amp;amp;m_timer, NRF_TIMER_TASK_CAPTURE0);

err_code = nrf_drv_ppi_channel_assign(ppi_channel_2, gpiote_evt_addr_2, timer_compare_task_addr);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_fork_assign(ppi_channel_2, timer_stop_task_addr);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_enable(ppi_channel_2);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer - nRF52833</title><link>https://devzone.nordicsemi.com/thread/271263?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 08:54:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af27e24c-c025-439c-bea6-40fc93640410</guid><dc:creator>Nguyen Trong Tuan</dc:creator><description>&lt;p&gt;Hi, thanks for your reply&lt;/p&gt;
&lt;p&gt;1. So if I want to use other TImer, what should I declare?&lt;/p&gt;
&lt;p&gt;2. Are there any example code about this? I need some references for this stuff!!!&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer - nRF52833</title><link>https://devzone.nordicsemi.com/thread/271022?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 09:29:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4537fa39-a17e-4c15-867d-f2cfe141c607</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1. Yes, the nRF52833 has &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/timer.html#topic"&gt;5 TIMER instances available&lt;/a&gt;. Instance 0 is used by the softdevice, if you are using that. The others are available for use by the application.&lt;/p&gt;
&lt;p&gt;2. This depends a bit on which events you are referring to, and what the goal you are trying to achieve is. You can use a TIMER to measure the time, by connecting the two events to the timer&amp;#39;s START and CAPTURE tasks, then read out the count from the CC register in an interrupt handler, etc., and convert this to elapsed time from the frequency that the timer was running at.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>