<?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>Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5477/setting-up-app_timer-results-in-hardware-fault</link><description>I started with the ble_app_template example. This example uses the Button event and notifies it. I modified the project to send some other data as notification, instead of the button state. And for the data to be read an transmitted, I initialized a timer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Jun 2015 07:49:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5477/setting-up-app_timer-results-in-hardware-fault" /><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19109?ContentTypeID=1</link><pubDate>Thu, 04 Jun 2015 07:49:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3712f85-3b77-4835-abfb-2f1afd597880</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;This is just code which hasn&amp;#39;t been properly updated for the change in APP_TIMER_INIT() between SDK7 and SDK8. The parameter to that used to be a bool, it was changed to a function pointer but not much of the example code has been updated and in most cases you don&amp;#39;t notice because false == 0 and it doesn&amp;#39;t make a difference.&lt;/p&gt;
&lt;p&gt;Using GCC with a reasonable set of warnings turned on I get a warning if I try compiling something like that. I don&amp;#39;t know if Keil is just not very good at warning about such things or the warnings are turned off by default. I always turn warning levels way up to catch all these things.&lt;/p&gt;
&lt;p&gt;I agree all the example code, most of which is &amp;#39;wrong&amp;#39; should be properly updated for SDK8.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19108?ContentTypeID=1</link><pubDate>Thu, 04 Jun 2015 07:23:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:866770a0-e5f7-4ee0-a880-41f8e1430c68</guid><dc:creator>Karel_TandD</dc:creator><description>&lt;p&gt;I am just starting out, and decided the best approach for me would be to start from scratch as you might say.
The first thing I noticed was in code, here and there, was the line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS,     APP_TIMER_OP_QUEUE_SIZE, false);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and in one place (as in the question above) I found a &lt;strong&gt;true&lt;/strong&gt;  (==&amp;gt; HARD FAULT)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS,     APP_TIMER_OP_QUEUE_SIZE, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;strong&gt;true&lt;/strong&gt; will lead to &lt;strong&gt;m_evt_schedule_func&lt;/strong&gt; being set to 1 and thus the code at&lt;br /&gt;
...\components\libraries\timer\app_timer.c(355)  will call a function at address 0x00000001&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (m_evt_schedule_func != NULL) 
{
    uint32_t err_code = m_evt_schedule_func(p_timer-&amp;gt;p_timeout_handler, p_timer-&amp;gt;p_context);
    ..DEATH..
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On investigating the parameters, I discovered that for the use of  &lt;strong&gt;true&lt;/strong&gt; / &lt;strong&gt;false&lt;/strong&gt; ,  one should be using&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please, everyone, check in the header files  &lt;code&gt;app_timer.h&lt;/code&gt;  and &lt;code&gt;app_timer_appsh.h&lt;/code&gt; yourselves.&lt;/p&gt;
&lt;p&gt;I am currently working with SDK8.0.0, so I don&amp;#39;t know if these &amp;#39;typos&amp;#39;  have been corrected in the latest release, but if not I would strongly recommend that the &lt;strong&gt;false&lt;/strong&gt; be changed to a &lt;strong&gt;NULL&lt;/strong&gt;, to avoid headaches in the future.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19106?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2015 22:28:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:899dc6cc-bfb2-4d7c-9b47-0b48b0d8b3d3</guid><dc:creator>perceptron</dc:creator><description>&lt;p&gt;I see that the debugger goes in to data_timeout_handler once and thereafter it does not. And it also seems like the debugger does not get into data_event_handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19105?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2015 21:57:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:988e29fa-c9af-477d-b41d-d2d5dfdebb59</guid><dc:creator>perceptron</dc:creator><description>&lt;p&gt;@Stefan Birnir Sverrisson thanks for your reply! Here is how the data_timeout_handler looks,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void data_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    data_event_handler(readData(0));
}

static void data_event_handler(uint16_t data)
{
    uint32_t err_code;
    err_code = ble_lbs_on_data_available(&amp;amp;m_lbs, data);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19107?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2015 12:34:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb85fcc1-807a-4ceb-93e2-31f942b1fd3c</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Have you defined your data_timeout_handler function? If so, what does the data_timeout_handler do? If you set a breakpoint in the data_timeout_handler, does the debugger stop there?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 10.2.2015&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In order for you to efficiently debug the application code in Keil, the setting should be however Optimization: “Level 0” and “Optimize for Time” should be unchecked&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Capture-_2D00_-compiler-optimization.JPG" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;Also check &lt;a href="https://devzone.nordicsemi.com/question/81/how-can-i-debug-a-softdevice-application/"&gt;this thread&lt;/a&gt; when debugging with a softdevice enabled.&lt;/p&gt;
&lt;p&gt;What SDK are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19104?ContentTypeID=1</link><pubDate>Sat, 07 Feb 2015 19:45:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ec4d9a0-8618-4e79-81f9-fe144cf2e685</guid><dc:creator>perceptron</dc:creator><description>&lt;p&gt;@RK, any clue ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19103?ContentTypeID=1</link><pubDate>Sat, 07 Feb 2015 07:10:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee6dbaf6-39d1-4360-ab07-d8ef3e93d212</guid><dc:creator>perceptron</dc:creator><description>&lt;p&gt;&amp;quot;m_ldc_timer_id&amp;quot; and &amp;quot;m_timer_id&amp;quot; are the same, I made a typo there. Both should have been m_ldc_timer_id. HEART_RATE_MEAS_INTERVAL is set to 32767 (for 1 second).&lt;/p&gt;
&lt;p&gt;The device does not go into hard fault while initializing the timer. The device initializes and goes on to execute the main loop (verified through debugger)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Enter main loop
    for (;;)
    {
        app_sched_execute();
        power_manage();
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On a BLE Scanner App I can see that it broadcasts and advertises in the beginning and then goes in to a hard fault.&lt;/p&gt;
&lt;p&gt;If I comment the timer initialization code, it seems to work fine. When I say works fine, I can see the device advertising and it appears on the BLE Scanner App. What is the best way to debug this ? Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting up APP_TIMER results in hardware fault</title><link>https://devzone.nordicsemi.com/thread/19102?ContentTypeID=1</link><pubDate>Sat, 07 Feb 2015 06:26:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23e9e5bc-de6e-4306-ab4c-72e197b33d63</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;What&amp;#39;s err_code in the timers_start() function? If not zero then APP_ERROR_CHECK() is sending you into an error.&lt;/p&gt;
&lt;p&gt;Why is your variable called m_ldc_timer_id in the initialization and m_timer_id in the timers_start function? What is HEART_RATE_MEAS_INTERVAL?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>