<?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>Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15265/using-application-timer-causes-hardfault-in-ble_app_uart-s120</link><description>I&amp;#39;ve modified the ble_app_uart example by adding GPIOTE so that the transmitter sends a character to the receiver when a GPIO pin is toggled. This part is working well. 
 Then, I used the application timer to count the number of falling edges occurring</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Jul 2016 07:41:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15265/using-application-timer-causes-hardfault-in-ble_app_uart-s120" /><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58320?ContentTypeID=1</link><pubDate>Thu, 28 Jul 2016 07:41:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3c2b26b-ee51-4d34-8a9d-4d74f79e1d8a</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;I decided to comment out most of my code leaving only the GPIOTE and BLE parts. They worked ok! So this suggests the issue was not due to any conflict between GPIOTE, TIMER and BLE. I will close the thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58319?ContentTypeID=1</link><pubDate>Thu, 28 Jul 2016 01:08:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8cdf633b-12ef-4f67-a509-b1871cdb9a8d</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;I moved gpiote_init below app_timer_create and still got the same issue. Worse, it did not even go to the breakpoint to find out the error code. It just froze.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58321?ContentTypeID=1</link><pubDate>Wed, 27 Jul 2016 08:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf15c558-1ef2-4166-aca3-50bb48c02a85</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;app_timer_start(..) will return error code NRF_ERROR_INVALID_STATE (0x08) either if &lt;code&gt;timer_id == 0&lt;/code&gt; or if the timeout handler is NULL. This can happen if app_timer_create(..) have not been called before app_timer_start(..) is called. You can try to call app_timer_create(..) before you initialize gpiote (gpiote_init()).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58318?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2016 05:30:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c727c824-3aaf-4d44-9ffd-26424f1032ae</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;I also want to add &lt;code&gt;AUDIO_STIM_PIN&lt;/code&gt; = pin 15 in the nRF dongle. The choice of the pin should not be a problem, should it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58317?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2016 05:26:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef1946d9-0247-4309-b2ec-02106c6e9c78</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;I followed the instruction to debug the code. When the code froze, the error handler was called. The error code was 0x00000008. It occurred when the app_timer_start was called.&lt;/p&gt;
&lt;p&gt;Interestingly, when I ran the debug again a few times, the error handler was not called again. It just froze.&lt;/p&gt;
&lt;p&gt;Here is the sequence of my code.&lt;/p&gt;
&lt;p&gt;In main, I initialised the GPIOTE and created the timer.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  gpiote_init();

  err_code = app_timer_create(&amp;amp;timer_stim_freq_id, APP_TIMER_MODE_REPEATED, timer_stim_freq_handler);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The timer ID was defined before main,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;APP_TIMER_DEF(timer_stim_freq_id);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I also changed APP_TIMER_OP_QUEUE_SIZE to 10. I don&amp;#39;t know if I need to change it - it did not make any noticeable difference.&lt;/p&gt;
&lt;p&gt;In gpiote_init, I define the interrupt handler: &lt;code&gt;audio_stimulus_handler&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = nrf_drv_gpiote_in_init(AUDIO_STIM_PIN, &amp;amp;fall_event_config, audio_stimulus_handler);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So when the GPIO detects a falling edge, this handler is called and in turn starts the timer.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void audio_stimulus_handler(void) 
{
	uint32_t err_code;
	switch (audio_stim_case)
	{
		case AUDIO_STIM_STATE_IDLE:
		{
			// Start the timer
			err_code = app_timer_start(timer_stim_freq_id, APP_TIMER_TICKS(AUDIO_STIM_MARKER_WINDOW, APP_TIMER_PRESCALER), NULL);
      APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, when the timer is time out, it calls the timer handler, which stops the timer.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void timer_stim_freq_handler(void * p_context)
{
	uint32_t err_code, diff_tick;
	switch (audio_stim_case)
	{
		case AUDIO_STIM_STATE_EVAL_FREQ:
		{
			// Update the state
			audio_stim_case = AUDIO_STIM_STATE_DONE;
			// Stop the timer and start again with a different timeout
			err_code = app_timer_stop(timer_stim_freq_id);
                       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: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58316?ContentTypeID=1</link><pubDate>Fri, 22 Jul 2016 06:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36a0f204-1b6e-456f-816d-170197b1b449</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Have a look at the question/answer I linked below and check the error code you are getting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58315?ContentTypeID=1</link><pubDate>Fri, 22 Jul 2016 06:18:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f31aa4b-8450-4173-82f6-7b2e07ca7ab2</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;There was no error message. It just froze.&lt;/p&gt;
&lt;p&gt;Here is the serial output without BLE.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;START: 10501  
PULSE FREQ: 1000
START: 76037
PULSE FREQ: 1000
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The difference in the counter time is about 65000 = 2 seconds&lt;/p&gt;
&lt;p&gt;Here is the serial output with BLE.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;START: 0
PULSE FREQ: 1000
S  &amp;lt;&amp;lt;== Frozen
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using application timer causes hardfault in ble_app_uart (S120) ?</title><link>https://devzone.nordicsemi.com/thread/58314?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 09:36:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95d85765-06ab-4085-88ef-26f23b3b92b6</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The application timer should work fine alongside the SoftDevice. For new designs we recommend using S130 which incorporates the functionality of s120 and s110.&lt;/p&gt;
&lt;p&gt;What error are you getting?&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this question/answer&lt;/a&gt; for more help on debugging using Keil.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>