<?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>Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84070/nrf52-simple-baremetal-timer-function-cpu-reset-if-interrupt-enabled</link><description>Trying to use the basic baremetal mode as my application is very simple and dont want to go through RTOS stuff. 
 I tried with Timer and RTC, both case if I enable the interrupt then the cpu gets rebooted. Following is the code, not sure if it is the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Jan 2022 14:22:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84070/nrf52-simple-baremetal-timer-function-cpu-reset-if-interrupt-enabled" /><item><title>RE: Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/thread/350239?ContentTypeID=1</link><pubDate>Fri, 28 Jan 2022 14:22:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af676ffc-fd32-4e4f-abd0-b2f3f25c9e94</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any project you build in Zephyr will have the Zephyr RTOS running underneath, and this affects how interrupts should be configured.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Essentially interrupts in Zephyr can be set up like&amp;nbsp;this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;IRQ_DIRECT_CONNECT(RTC0_IRQn, 0, my_rtc0_irq_handler, 0);
irq_enable(RTC0_IRQn);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;More information about the IRQ_CONNECT and IRQ_DIRECT_CONNECT macros can be found &lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/other/interrupts.html#c.IRQ_CONNECT"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/thread/350065?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 17:32:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48426727-2e87-477c-a176-d17e2d49dbb8</guid><dc:creator>Abir Hossain</dc:creator><description>&lt;p&gt;Thanks for the reply both ovrebekk and hmlesworth. I will try this changes too.&lt;br /&gt;But I think it is more of a project setup issue.&lt;br /&gt;&lt;br /&gt;I tried similar code on uVision and working fine. I am using Vscode and used an example Zphyre project as templete. So My guess is some components/config from Zphyre is conflicting with my attempt to make project baremetal. Thats why added the project here.&lt;br /&gt;&lt;br /&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/thread/350064?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 17:31:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2deb2b6-8cb6-4870-8eac-446376906352</guid><dc:creator>Abir Hossain</dc:creator><description>&lt;p&gt;Thanks for the reply both ovrebekk and hmlesworth. I will try this changes too.&lt;br /&gt;But I think it is more of a project setup issue.&lt;br /&gt;&lt;br /&gt;I tried similar code on uVision and working fine. I am using Vscode and used an example Zphyre project as templete. So My guess is some components/config from Zphyre is conflicting with my attempt to make project baremetal. Thats why added the project here.&lt;br /&gt;&lt;br /&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/thread/350063?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 17:27:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b9fc8e8-b2c1-4374-9a88-7796460edaa4</guid><dc:creator>Abir Hossain</dc:creator><description>&lt;p&gt;The board is nrf52-DK, nrf52832, official board&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/basic_2D00_timer.zip"&gt;devzone.nordicsemi.com/.../basic_2D00_timer.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/thread/350043?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 16:16:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73320510-27e9-434e-b0a1-9ac9d8844b95</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Try this and also init the i/o pin before enabling the timer:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/ This IRQ handler will trigger every 30.5 ms
void RTC0_IRQHandler(void)
{
  if (NRF_RTC0-&amp;gt;EVENTS_COMPARE[0] == 1)
  {
    NRF_RTC0-&amp;gt;EVENTS_COMPARE[0] = 0;
    // COUNTER and COMPARE[n] registers are all 24-bit. It seems an intermediate sampled
    // value must be used as pRTC-&amp;gt;CC[IDX_SYS_TICK] += N; does not work for some reason,
    // maybe requires so many cycles to read back and CountValue must be synchronous (unchanging)
    //  - COUNTER register read takes a fixed 5 x PCLK16M clock cycles
    volatile uint32_t CountValue = NRF_RTC0-&amp;gt;COUNTER;
    // Increment compare value with 30.5 ms from current time.
    NRF_RTC0-&amp;gt;CC[0] = CountValue + 1000;
    // Data Synchronization Barrier: completes when all explicit memory accesses before
    // last instruction completes to avoid spurious interrupt
    __DSB();
  }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52 simple Baremetal timer function, CPU reset if interrupt enabled.</title><link>https://devzone.nordicsemi.com/thread/349913?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 10:01:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55de9a85-f5d1-4720-a577-9e7e22538f00</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Abir&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t use a SoftDevice I don&amp;#39;t know why this code would cause a crash.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you let me know what kind of hardware you are testing on?&lt;/p&gt;
&lt;p&gt;Is it a standard DK, or some other kind of board?&lt;/p&gt;
&lt;p&gt;If you can upload the entire project that would be great, then I can easily test it here. It should be enough to drag drop a file into your reply if you want to attach files.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>