<?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>RTC interrupt problems</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87271/rtc-interrupt-problems</link><description>Hi, 
 I have a problem getting interrupts by the rtc component working. I am using the nrf58211 chip, nRF Connect SDK v. 1.9, uBlox BMD360-eval development board. 
 My code looks like this: 
 
 I want: An Interrupt to be triggered 5s after initialization</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Apr 2022 17:30:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87271/rtc-interrupt-problems" /><item><title>RE: RTC interrupt problems</title><link>https://devzone.nordicsemi.com/thread/365023?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 17:30:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:747016bc-8916-4ce0-9725-6e89e5b0e8cf</guid><dc:creator>TimK</dc:creator><description>&lt;p&gt;Hi Andreas,&lt;/p&gt;
&lt;p&gt;thank you very much for this detailed answer and general debugging help.&lt;/p&gt;
&lt;p&gt;The project you provided works for me as well but when I enable bluetooth (CONFIG_BT=y in prj.conf) the interrupts are not triggered anymore. My code works as well, when the SoftDevice is turned off.&lt;/p&gt;
&lt;p&gt;The reason for this is: SoftDevice uses RTC0 (like mentioned in this ticket &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/13264/using-rtc-driver-with-softdevice"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/13264/using-rtc-driver-with-softdevice&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;If RTC1 is used by zephyr this only leaves me with RTC2, but I dont think my chip is equipped with a third RTC peripheral.&lt;/p&gt;
&lt;p&gt;Anyways my goal is to put my application into a powersaving mode for a few minutes and then send a bluetooth advertisement. I think I need to go with either a Zephyr or SoftDevice API to archieve this.&lt;/p&gt;
&lt;p&gt;Because my initial questioned is answered, I will close the ticket.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;TLDR: Zephyr uses RTC1, SoftDevice RTC0 so they can&amp;#39;t be used for your application&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC interrupt problems</title><link>https://devzone.nordicsemi.com/thread/364873?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 09:07:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc9e9491-dc57-427c-818f-1a3fd7a2f2bb</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi Tim&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="TimK"]If I use RTC1 i get a compile error[/quote]
&lt;p&gt;I was able to recreate the same error with RTC1. As far as I can see from&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/76568/can-i-use-two-rtc-in-nrf5340"&gt;this somewhat similar ticket&lt;/a&gt;&amp;nbsp;for nRF5340, RTC1 is reserved for the Zephyr RTOS kernel timer which might cause the invocation of &amp;quot;&lt;em&gt;Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times&amp;quot;.&amp;nbsp;&lt;/em&gt;I will keep on investigating if this is the same for a nRF52811 which you&amp;#39;re working with, but in the meanwhile you may try to base your sample on the same zip-sample in that ticket (also added here).&lt;/p&gt;
&lt;p&gt;Regarding the first issue, did you get it by running both the same sample I posted in my previous reply as well as the full code you posted in your initial post?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;br /&gt;For investigating this you can check the function addresses that return causes the &lt;em&gt;kernel oops&lt;/em&gt; by running the following lines in a cmd, but it will only work if you added GNUARMEMB to path, which you can verify by running the line in 1) in cmd.&lt;/p&gt;
&lt;p&gt;1)&amp;nbsp;&lt;em&gt;&amp;quot;&lt;span&gt;where arm-none-eabi-addr2line&amp;quot;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It should return something like this: &lt;em&gt;&amp;quot;C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin\arm-none-eabi-addr2line.exe&amp;quot;.&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If it returns something that indicates that it is not on the path, you may try to follow this step in&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_installing.html#install-the-gnu-arm-embedded-toolchain"&gt;a manual installation guide&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;Then run the two following lines separately where you replace &amp;quot;&lt;span&gt;&amp;lt;path to build\zephyr\zephyr.elf&amp;gt;&amp;quot; with the actual path&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;2) &amp;quot;&lt;span&gt;arm-none-eabi-addr2line -e &amp;lt;path to build\zephyr\zephyr.elf&amp;gt; 0x00010d06&amp;quot; for r15/pc&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and &amp;quot;&lt;/span&gt;&lt;span&gt;arm-none-eabi-addr2line -e &amp;lt;path to build\zephyr\zephyr.elf&amp;gt; 0x0000c3cf&amp;quot; for r14/lr&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If 1) returns the path, then 2) should return the lines in which functions that causes the issue and might give us a clue about the issue.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Let me know if any of this helps and your progress with&amp;nbsp;the debugging.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;br /&gt;Andreas&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4810.nrfx_5F00_rtc.zip"&gt;devzone.nordicsemi.com/.../4810.nrfx_5F00_rtc.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC interrupt problems</title><link>https://devzone.nordicsemi.com/thread/364782?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 20:13:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18484878-2ac3-4468-bfd9-c7ab7c8086d8</guid><dc:creator>TimK</dc:creator><description>&lt;p&gt;Hello Andreas,&lt;/p&gt;
&lt;p&gt;thank you for your quick response. I must admit, i did not give you the full story. My code also uses the SoftDevice and TIMER1 and this seems to have issues (i persume soft device uses rtc0 in some sort).&lt;/p&gt;
&lt;p&gt;So if I use RTC0 the board crashes with the following printed at COM0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2022_2D00_04_2D00_25-220752.png" /&gt;&lt;/p&gt;
&lt;p&gt;If I use RTC1 i get a compile error&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2022_2D00_04_2D00_25-221050.png" /&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have that much time at the moment so I could not do a deeper analysis. Anyways, I am looking forward to receiving any suggestions.&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC interrupt problems</title><link>https://devzone.nordicsemi.com/thread/364705?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 12:06:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66a98a0f-5447-4453-96a9-836b7534daae</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi Tim,&lt;br /&gt;&lt;br /&gt;Did you include the header file nrfx_rtc.h? If no, add&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;nrfx_rtc.h&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If this was not your issue, then I&amp;#39;m going to need more information. Do you get any warnings/errors when building/flashing or running the code? I was not able to recreate any errors myself when testing your configuration.&lt;/p&gt;
&lt;p&gt;Edit: Add a print statement to your callback function to see if it works as intended. The following&amp;nbsp;sample does what it is written to do without resetting the board&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;

#include &amp;quot;nrfx_rtc.h&amp;quot;

static nrfx_rtc_t powerdown_rtc = NRFX_RTC_INSTANCE(0);

static void powerdown_rtc_handler(nrfx_rtc_int_type_t int_type){
    nrfx_rtc_counter_clear(&amp;amp;powerdown_rtc);
    printk(&amp;quot;Inside callback\n&amp;quot;);
}

void init_rtc(){
        printk(&amp;quot;Initializing rtc\n&amp;quot;);
    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(rtc0)),
                DT_IRQ(DT_NODELABEL(rtc0), priority),
                nrfx_isr, nrfx_rtc_0_irq_handler, 0);

    nrfx_rtc_config_t config = NRFX_RTC_DEFAULT_CONFIG;
    config.prescaler = RTC_FREQ_TO_PRESCALER(1); // set to 1 HZ
    nrfx_rtc_init(&amp;amp;powerdown_rtc, &amp;amp;config, powerdown_rtc_handler);
    nrfx_rtc_tick_disable(&amp;amp;powerdown_rtc);
    nrfx_rtc_counter_clear(&amp;amp;powerdown_rtc);

    nrfx_rtc_cc_set(&amp;amp;powerdown_rtc, 0, 5, true);
    nrfx_rtc_int_enable(&amp;amp;powerdown_rtc, NRF_RTC_INT_COMPARE0_MASK);
    nrfx_rtc_enable(&amp;amp;powerdown_rtc);
}

void main(void){

        init_rtc();
        k_msleep(5000);
        printk(&amp;quot;Hello World! %s\n&amp;quot;, CONFIG_BOARD);
        // while(1){
        //         printk(&amp;quot;Hello World! %s\n&amp;quot;, CONFIG_BOARD);

        //         k_msleep(5000);
        // }

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>