<?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>[nRF52833]  TIMER3 does not enter IRQ and keeps going</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116569/nrf52833-timer3-does-not-enter-irq-and-keeps-going</link><description>Hello, 
 I am trying to use TIMER3 where it should count 1ms ticks for 15 seconds and then stop. 
 Tried the below code. However it never enters ISR. 
 Please let me know if I am configuring it incorrectly or something else. 
 As Channel 0 is being used</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Nov 2024 13:55:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116569/nrf52833-timer3-does-not-enter-irq-and-keeps-going" /><item><title>RE: [nRF52833]  TIMER3 does not enter IRQ and keeps going</title><link>https://devzone.nordicsemi.com/thread/512595?ContentTypeID=1</link><pubDate>Thu, 28 Nov 2024 13:55:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf27453a-0584-465b-90fe-b3851697cb31</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;We will continue in your private ticket.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [nRF52833]  TIMER3 does not enter IRQ and keeps going</title><link>https://devzone.nordicsemi.com/thread/511970?ContentTypeID=1</link><pubDate>Mon, 25 Nov 2024 16:47:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ce51ce8-b4b1-4939-bac2-ac67675f7b9a</guid><dc:creator>abhiash_sl</dc:creator><description>&lt;p&gt;Initially was a bit unsure. Now I know that each Timer has own CC channel set.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I can share the application in a private ticket.&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [nRF52833]  TIMER3 does not enter IRQ and keeps going</title><link>https://devzone.nordicsemi.com/thread/511932?ContentTypeID=1</link><pubDate>Mon, 25 Nov 2024 14:19:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:431d6782-bfa9-4a32-b04c-81a348d3fc58</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am not quite sure why it is not working, based on your snippets. Is it possible to upload the application?&lt;/p&gt;
[quote user=""]As Channel 0 is being used by Timer 2 already, I have chosen channel 3.[/quote]
&lt;p&gt;This doesn&amp;#39;t make any sense to me. Do you mean &amp;quot;I have chosen Timer 3&amp;quot;? Each timer has it&amp;#39;s own CC channels.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [nRF52833]  TIMER3 does not enter IRQ and keeps going</title><link>https://devzone.nordicsemi.com/thread/511859?ContentTypeID=1</link><pubDate>Mon, 25 Nov 2024 10:24:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5db37c3-0a9b-4d20-a3c2-2b2b75d8b79d</guid><dc:creator>abhiash_sl</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I also tried to implement single shot hardware timer using instance 1, channel 0 using PPI and GPIOTE.&lt;/p&gt;
&lt;p&gt;However the Timer continues to run even after the single shot period and never enters the ISR also.&lt;/p&gt;
&lt;p&gt;Tried both APIs&amp;nbsp;&lt;/p&gt;
&lt;p&gt;rf_drv_timer_extended_compare()&amp;nbsp; and&amp;nbsp;nrf_drv_timer_compare()&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;NRF_TIMER_SHORT_COMPARE0_STOP_MASK does not really stop the timer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The requirement is to use hardware timer for 30s or more and after it&amp;#39;s expiry raise a GPIO&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define TIMER_TICK_1MS                 16000
#define TICKS_DURATION_30S             (30000 * TIMER_TICK_1MS)

static void ppi_init(void)
{
    uint32_t err_code = NRF_SUCCESS;

    //Initialize the PPI driver
    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);
    
   // Allocate the first unused PPI channel 
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel1);
    APP_ERROR_CHECK(err_code);
    
    
    // Assigning task and event endpoints so that the PPI channel triggers the OUT task of the LED_1 GPIO pin on TIMER0 COMPARE[0] match.
    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1,
                                          nrf_drv_timer_event_address_get(&amp;amp;m_timer1, NRF_TIMER_EVENT_COMPARE0),
                                          nrf_drv_gpiote_out_task_addr_get(LED_1)); 
    APP_ERROR_CHECK(err_code);
      

    // Enable the PPI channel 
    err_code = nrf_drv_ppi_channel_enable(m_ppi_channel1);
    APP_ERROR_CHECK(err_code);
}


void timer1_event_handler(nrf_timer_event_t event_type, void * p_context)
{
    switch(event_type)
    {
        case NRF_TIMER_EVENT_COMPARE0:
            nrf_drv_gpiote_out_task_trigger(LED_1);
            NRF_LOG_INFO(&amp;quot;Toggle LED1 \r\n&amp;quot;);
            break;
        default:
            // Do nothing.
            break;
    }
    
}


static void hw_timer1_init(void) 
{
    
    ret_code_t err_code;
    
    // Configure the timer to use the default configuration set in sdk_config.h
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    
    //Initializing the Timer driver
    err_code = nrf_drv_timer_init(&amp;amp;m_timer1, &amp;amp;timer_cfg, timer1_event_handler);
    APP_ERROR_CHECK(err_code);
    
    /*Configure the timer to generate the COMPARE event after 200*1000UL ticks and enable the shortcut that triggers the CLEAR task on every COMPARE event. */
    
    // nrf_drv_timer_extended_compare(&amp;amp;m_timer1, NRF_TIMER_CC_CHANNEL0, TICKS_DURATION_30S, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK |NRF_TIMER_SHORT_COMPARE0_STOP_MASK, true); // Set last argument to false for Task 3
    nrf_drv_timer_compare(&amp;amp;m_timer1, NRF_TIMER_CC_CHANNEL0, TICKS_DURATION_30S, true);

    nrfx_timer_compare_int_enable(&amp;amp;m_timer1,NRF_TIMER_CC_CHANNEL0);

    // Turning on the Timer. 
    nrf_drv_timer_enable(&amp;amp;m_timer1);
}


static void gpiote_init(void) 
{    
    ret_code_t err_code;
    
    // Check wether the GPIOTE driver has been initialized before by any other module, e.g. app_button_init().
    if (!nrf_drv_gpiote_is_init())
    {
        // Initialize the GPIOTE driver
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }

    // Configure the GPIO pin so that its toggled every time the OUT task is triggerd
    nrf_drv_gpiote_out_config_t config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(false); 
    
    // Apply the configuration above to the LED_1 GPIO pin.  
    err_code = nrf_drv_gpiote_out_init(LED_1, &amp;amp;config);
    APP_ERROR_CHECK(err_code);
       
    // Enabling the OUT task for the LED_1 GPIO pin.
    nrf_drv_gpiote_out_task_enable(LED_1);
}


int main()
{
    gpiote_init();  // Initialize GPIO
    ppi_init();     // Initialize PPI

    NRF_LOG_INFO(&amp;quot;Init and Starting Timer 1&amp;quot;);
    hw_timer1_init();
    
    
    for (;;)
    {
        idle_state_handle();

        l_ticks = timer1_get_ticks();
        NRF_LOG_INFO(&amp;quot; l_ticks = %u&amp;quot;, l_ticks);
        NRF_LOG_FLUSH();

        nrf_delay_ms(10000);
    }

}


&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [nRF52833]  TIMER3 does not enter IRQ and keeps going</title><link>https://devzone.nordicsemi.com/thread/511556?ContentTypeID=1</link><pubDate>Thu, 21 Nov 2024 17:17:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ea199d6-7f72-4945-b052-9f84fe9b547e</guid><dc:creator>abhiash_sl</dc:creator><description>&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have observed that if there is no processing or printing etc. in main() then the IRQ Handler is hit and if I had some logic like below in main loop,&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;g_ticks = timer3_get_ticks();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NRF_LOG_INFO(&amp;quot;T3 g_ticks = %u &amp;quot;, g_ticks);&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;then the Timer3 never goes into the IRQ handler and keeps on running.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>