<?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>app_scheduler and TIMER1 hardfault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10361/app_scheduler-and-timer1-hardfault</link><description>I have the code below initializing TIMER1 and and IRQ every 1ms. I call app_sched_event_put within the timer and I get a Hardfault. 
 Any hints on what is going on ? 
 Thanks. 
 void high_res_timer_init(){
 // Stop timers
 NRF_TIMER1-&amp;gt;TASKS_STOP</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Nov 2015 07:27:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10361/app_scheduler-and-timer1-hardfault" /><item><title>RE: app_scheduler and TIMER1 hardfault</title><link>https://devzone.nordicsemi.com/thread/38442?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2015 07:27:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cff84de6-e5bb-40b6-a191-953668d52c4a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;nRF51 has Cortex M0 processor which allows only four programmable priority levels (0-3). Setting any thing else than that will obviously hardfault immediately on the chip level. Please use only APP_PRIORITY_HIGH or APP_PRIORITY_LOW macro for application specific priority levels.
If you use APP_PRIORITY_HIGH, then it will be higher priority than SVC calls and hence your application wont be able to make any softdevice calls in this interrupt priority context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_scheduler and TIMER1 hardfault</title><link>https://devzone.nordicsemi.com/thread/38441?ContentTypeID=1</link><pubDate>Sun, 22 Nov 2015 04:30:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:754c5448-cd86-4ca4-aaf3-b7c6bc53357b</guid><dc:creator>Xian</dc:creator><description>&lt;p&gt;Thank you, this is the root of the issue. I am facing now an issue as I also have a GPIOTE interrupt event with the same APP_PRIORITY_LOW and they are fighting one against each other. I tried to set one of them to a lower priority (4) but then it would just hardfault again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_scheduler and TIMER1 hardfault</title><link>https://devzone.nordicsemi.com/thread/38440?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2015 05:29:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe2523da-9dfc-44ff-917a-0cfe36e032ec</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;EricS is right, ill explain little more of what he said. It must be happening when calling &lt;code&gt;CRITICAL_REGION_ENTER();&lt;/code&gt; inside &lt;code&gt;app_sched_event_put&lt;/code&gt;. This happens when your timer interrupt handler priority is higher than SVC priority (2) and you have defined&lt;code&gt;SOFTDEVICE_PRESENT&lt;/code&gt; in your project.&lt;/p&gt;
&lt;p&gt;Setting below when initializing the timer interrupt should do the trick.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NVIC_SetPriority(TIMER1_IRQn, APP_IRQ_PRIORITY_LOW);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_scheduler and TIMER1 hardfault</title><link>https://devzone.nordicsemi.com/thread/38438?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 23:47:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b883a74e-e00b-4475-84e7-5bd05903309b</guid><dc:creator>Eric Stutzenberger</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure of the default interrupt priority off the top of my head, but when setting up the interrupt, the priority should be set to either app high or app low.  Not sure how critical this particular functionality is but I&amp;#39;d suggest setting the priority to see if it helps in anyway:
NVIC_SetPriority(TIMER1_IRQn, APP_IRQ_PRIORITY_LOW); //APP_IRQ_PRIORITY_LOW defined in app_util_platform.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_scheduler and TIMER1 hardfault</title><link>https://devzone.nordicsemi.com/thread/38439?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 21:25:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a24315e-d2e5-41ad-bcb3-94215e60c635</guid><dc:creator>Eric Stutzenberger</dc:creator><description>&lt;p&gt;Can you provide more details about what line of code causes the hard fault?  I haven&amp;#39;t used the app scheduler much.  Is it somewhere within app_sched_event_put()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>