<?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 channels</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91817/timer-channels</link><description>#include &amp;lt;stdbool.h&amp;gt; #include &amp;lt;stdio.h&amp;gt; #include &amp;lt;stdint.h&amp;gt; #include &amp;quot;nrf.h&amp;quot; #include &amp;quot;nrf_drv_timer.h&amp;quot; #include &amp;quot;bsp.h&amp;quot; #include &amp;quot;app_error.h&amp;quot; #include &amp;quot;nrf_gpio.h&amp;quot; #define LED1 13 #define LED2 14 #define LED3 15 #define Button 11 #define Button1 12</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Sep 2022 09:40:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91817/timer-channels" /><item><title>RE: Timer channels</title><link>https://devzone.nordicsemi.com/thread/385669?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 09:40:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf4fdb99-de50-4d94-bae3-b0e3762721d1</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;Are you using the nRF52840 DK? Most likely, the GPIO button value isn&amp;#39;t read correctly resulting in the program never entering the conditional statement since n/m = 12 and again resulting in the leds not being toggled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer channels</title><link>https://devzone.nordicsemi.com/thread/385582?ContentTypeID=1</link><pubDate>Sat, 10 Sep 2022 05:29:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec2f9fd5-3103-43d2-9c87-2e130963c3a4</guid><dc:creator>KJNK</dc:creator><description>&lt;p&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.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;br /&gt;#include &amp;quot;nrf_gpio.h&amp;quot;&lt;br /&gt;#define LED1 13&lt;br /&gt;#define LED2 14&lt;br /&gt;#define LED3 15&lt;br /&gt;#define Button 11&lt;br /&gt;#define Button1 12&lt;br /&gt;static nrfx_timer_t timer=NRFX_TIMER_INSTANCE(0);&lt;br /&gt;static int n=12,m=12;&lt;br /&gt;void time_handler(nrf_timer_event_t event_type, void* p_context)&lt;br /&gt;{ &lt;br /&gt; switch (event_type)&lt;br /&gt; {&lt;br /&gt; case NRF_TIMER_EVENT_COMPARE0:&lt;br /&gt; {&lt;br /&gt; if(n&amp;lt;11)&lt;br /&gt; {&lt;br /&gt; nrf_gpio_pin_toggle(LED1);&lt;br /&gt; printf(&amp;quot;%d&amp;quot;,n);//debug &lt;br /&gt; n++;&lt;br /&gt; if(n==10)&lt;br /&gt; {&lt;br /&gt; nrf_gpio_pin_clear(LED1);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;case NRF_TIMER_EVENT_COMPARE1:&lt;br /&gt; {&lt;br /&gt; if(m&amp;lt;11)&lt;br /&gt; {&lt;br /&gt; nrf_gpio_pin_toggle(LED2);&lt;br /&gt; printf(&amp;quot;%d&amp;quot;,m);//debug&lt;br /&gt; m++;&lt;/p&gt;
&lt;p&gt;if(m==10)&lt;br /&gt; {&lt;br /&gt; nrf_gpio_pin_clear(LED2);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; break;&lt;br /&gt; &lt;br /&gt; default:&lt;br /&gt; break;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; uint32_t time_ticks,time_ticks1,count=0;&lt;br /&gt; uint32_t time_ms=0;&lt;br /&gt; &lt;br /&gt; nrfx_timer_config_t configure = NRFX_TIMER_DEFAULT_CONFIG;&lt;br /&gt; &lt;br /&gt; nrfx_timer_init(&amp;amp;timer,&amp;amp;configure,time_handler);&lt;br /&gt; &lt;br /&gt; time_ms +=50;&lt;br /&gt; printf(&amp;quot;%d\n&amp;quot;,time_ms);&lt;br /&gt; time_ticks=nrfx_timer_ms_to_ticks(&amp;amp;timer,time_ms);&lt;br /&gt; printf(&amp;quot;%d\n&amp;quot;,time_ticks);&lt;br /&gt; nrfx_timer_extended_compare(&amp;amp;timer,NRF_TIMER_CC_CHANNEL0,time_ticks,0,true);&lt;/p&gt;
&lt;p&gt;time_ms +=50;&lt;br /&gt; printf(&amp;quot;%d\n&amp;quot;,time_ms);&lt;br /&gt; time_ticks=nrfx_timer_ms_to_ticks(&amp;amp;timer,time_ms);&lt;br /&gt; printf(&amp;quot;%d\n&amp;quot;,time_ticks);&lt;br /&gt; nrfx_timer_extended_compare(&amp;amp;timer,NRF_TIMER_CC_CHANNEL1,time_ticks,NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK,true);&lt;br /&gt; &lt;br /&gt; nrfx_timer_enable(&amp;amp;timer);&lt;/p&gt;
&lt;p&gt;nrf_gpio_cfg_output(LED1);&lt;br /&gt; nrf_gpio_cfg_output(LED2);&lt;br /&gt; &lt;br /&gt; nrf_gpio_cfg_input(Button,NRF_GPIO_PIN_PULLUP);&lt;br /&gt; nrf_gpio_cfg_input(Button1,NRF_GPIO_PIN_PULLUP);&lt;br /&gt; while(1)&lt;br /&gt; {&lt;br /&gt; if(nrf_gpio_pin_read(Button)==0)&lt;br /&gt; { &lt;br /&gt; n=0;&lt;br /&gt; }&lt;br /&gt; if(nrf_gpio_pin_read(Button1)==0)&lt;br /&gt; { &lt;br /&gt; m=0;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I changed the timing value by adding the value is changes but the output to led does not changes..HELP ME SIR&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer channels</title><link>https://devzone.nordicsemi.com/thread/385562?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 16:45:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37ad606a-99dd-4084-96b9-089f6411b86f</guid><dc:creator>Daniel Chisholm</dc:creator><description>&lt;p&gt;You are setting a&amp;nbsp;&lt;span&gt;NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK at 1000ms and also a NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK at 5000ms.&amp;nbsp; This means that the counter will be reset every 1000ms, so the second compare event (at 5000ms) will never happen.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You could instead let the timer be free running (and wrap around from time to time).&amp;nbsp; Then every time the interrupt handler is called, reset the next compare event to be +1000ms/+5000ms into the future.&amp;nbsp; Do an unsigned add and things will wrap as needed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>