<?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>NRF51 RTC bug if event and interrupt are defined but not CC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9603/nrf51-rtc-bug-if-event-and-interrupt-are-defined-but-not-cc</link><description>Dear Nordic Support Team, 
 Defining NRF_RTC1-&amp;gt;EVTENSET = RTC_EVTEN_COMPARE3_Msk; and NRF_RTC1-&amp;gt;INTENSET = RTC_INTENSET_COMPARE3_Msk; without specifing NRF_RTC1-&amp;gt;CC[3] and NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] handler management resulting by freezing the nRF51822</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 07 Oct 2015 21:23:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9603/nrf51-rtc-bug-if-event-and-interrupt-are-defined-but-not-cc" /><item><title>RE: NRF51 RTC bug if event and interrupt are defined but not CC</title><link>https://devzone.nordicsemi.com/thread/35480?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2015 21:23:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f63ecb4-96fd-4a85-b437-8e92bc9c75fb</guid><dc:creator>S&amp;#233;bastien Despont</dc:creator><description>&lt;p&gt;Thanks for your explanation Aryan. I know that it is nonsense to do that, I just forgot to remove the lines to set event and interrupt in my code. But this problem was pretty hard to figure out because everything is working normally for 8 minutes, then boom.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 RTC bug if event and interrupt are defined but not CC</title><link>https://devzone.nordicsemi.com/thread/35477?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2015 16:56:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34714647-025a-4785-8045-a3b644e805b0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;if you comment this, then the interrupt handler will be triggered immediately after it exits, because the system will think it is a new event that happened after its ISR was called. maybe this is what you mean by system being non responsive. This is because RTC1 ISR being called infinetely and not allowing anything else to execute.. It is important to the clear the event to correctly detect the next one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 RTC bug if event and interrupt are defined but not CC</title><link>https://devzone.nordicsemi.com/thread/35479?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2015 14:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82a5a753-1d61-468a-8f52-16ce3a7f96ca</guid><dc:creator>S&amp;#233;bastien Despont</dc:creator><description>&lt;p&gt;Even if you comment :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] != 0)
    {
        NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] = 0;
        LEDS_INVERT(1 &amp;lt;&amp;lt; LED_4);
    }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 RTC bug if event and interrupt are defined but not CC</title><link>https://devzone.nordicsemi.com/thread/35478?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2015 13:12:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff408c72-9afe-44a1-b91d-32db6be63b2b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;LED4 is inverting every 512 seconds as it should&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 RTC bug if event and interrupt are defined but not CC</title><link>https://devzone.nordicsemi.com/thread/35476?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2015 13:12:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd0a53c6-9b36-407d-8e58-bc64e28baff0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;working just fine.&lt;/p&gt;
&lt;p&gt;tested with below code on PCA10028&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;

#define LEDS_NUMBER    3    
#define LEDS_LIST { LED_1, LED_2, LED_3 }
const uint8_t leds_list[LEDS_NUMBER] = LEDS_LIST;
#define APP_TIMER_PRESCALER     0  
#define APP_IRQ_PRIORITY_LOW  3
#define TIMER_INTERVAL  0xFF


/**@brief 
 * Function for initializing the RTC1 counter.
 */
static void rtc1_init()
{   
    NRF_CLOCK-&amp;gt;LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART    = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0)
    {
        // Do nothing.
    }
    
    NRF_RTC1-&amp;gt;PRESCALER = APP_TIMER_PRESCALER;
    NVIC_SetPriority(RTC1_IRQn, APP_IRQ_PRIORITY_LOW);

    NVIC_ClearPendingIRQ(RTC1_IRQn);
    NVIC_EnableIRQ(RTC1_IRQn);

    // Configure timer for clock
    NRF_RTC1-&amp;gt;EVENTS_COMPARE[0] = 0;
    NRF_RTC1-&amp;gt;CC[0] = 0XF;
    NRF_RTC1-&amp;gt;EVTENSET = RTC_EVTEN_COMPARE0_Msk;
    NRF_RTC1-&amp;gt;INTENSET = RTC_INTENSET_COMPARE0_Msk;
    
    NRF_RTC1-&amp;gt;EVTENSET = RTC_EVTEN_COMPARE3_Msk;
    NRF_RTC1-&amp;gt;INTENSET = RTC_INTENSET_COMPARE3_Msk;

    //NRF_RTC1-&amp;gt;CC[3] = 0XFF;      //If not defined, the chip will freeze in 512 seconds

    NRF_RTC1-&amp;gt;TASKS_START = 1;
    nrf_delay_us(50);  
}

/**@brief Function for handling the RTC1 interrupt.
 *
 */
void RTC1_IRQHandler(void)
{
    if (NRF_RTC1-&amp;gt;EVENTS_COMPARE[0] != 0)
    {
        NRF_RTC1-&amp;gt;EVENTS_COMPARE[0] = 0;
        NRF_RTC1-&amp;gt;CC[0] += TIMER_INTERVAL;
    }

    if (NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] != 0)
    {
        NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] = 0;
        LEDS_INVERT(1 &amp;lt;&amp;lt; LED_4);
    }

    
    /*
    if(NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] != 0)
    {
        NRF_RTC1-&amp;gt;EVENTS_COMPARE[3] = 0;

        //Watch Dog
        NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;

        NRF_RTC1-&amp;gt;CC[3] += TICKS_1_SEC;

       increment_time();            
       kernel_setSignal(SIGNAL_1HZ);                    
    }
   */
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    // Configure LED-pins as outputs.
    LEDS_CONFIGURE(LEDS_MASK);

    rtc1_init();
    while (true)
    {
        for (int i = 0; i &amp;lt; LEDS_NUMBER; i++)
        {
            LEDS_INVERT(1 &amp;lt;&amp;lt; leds_list[i]);
            nrf_delay_ms(500);
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>