<?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>BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18640/ble-adc-timer</link><description>Hey everyone. I&amp;#39;m trying to read ADC value from sensor and send it via ble. 
 I use timer to get the value from sensor every 5 seconds, however ADC interruption correlates with BLE interruption and I get an error via serial port 
 APP_ERROR:ERROR:Fatal</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Jan 2017 09:18:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18640/ble-adc-timer" /><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72010?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 09:18:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a20f0084-d513-4243-9b57-7431414b1fbf</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The potential error codes are listed in the API documentation, see for example sd_ble_gatts_hvx(). See the definition of these to see the value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72009?ContentTypeID=1</link><pubDate>Thu, 05 Jan 2017 18:19:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17577c8a-2022-4ef8-856f-fed9267b5ccb</guid><dc:creator>IlyaM</dc:creator><description>&lt;p&gt;Thank you! Could you tell me where can I find all descriptions of error codes like this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72008?ContentTypeID=1</link><pubDate>Thu, 05 Jan 2017 14:12:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22d9a675-e5e8-4471-a796-c3bcd38322e0</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;13313 = 0x3401 = BLE_ERROR_GATTS_SYS_ATTR_MISSING which is probably returned from sd_ble_gatts_hvx() inside ble_hts_measurement_send().&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://devzone.nordicsemi.com/question/102665/ble_error_gatts_sys_attr_missing-from-sd_ble_gatts_hvx/"&gt;this&lt;/a&gt; for how to handle it. &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v3.0.0/group___b_l_e___g_a_t_t_s___h_v_x___s_y_s___a_t_t_r_s___m_i_s_s_i_n_g___m_s_c.html?cp=2_3_0_1_1_2_4_3_4"&gt;This&lt;/a&gt; MSC may also be of interest.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72007?ContentTypeID=1</link><pubDate>Thu, 05 Jan 2017 13:57:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43371c97-5b45-418a-8700-5cd67c3ba6d2</guid><dc:creator>IlyaM</dc:creator><description>&lt;p&gt;yes, I put breakpoint and got error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;error_code: 13313
in this code

if (!m_hts_meas_ind_conf_pending)
    {
        hts_sim_measurement(&amp;amp;simulated_meas, value);
        NRF_LOG_INFO(&amp;quot;hts_sim_measurement\r\n&amp;quot;);
        err_code = ble_hts_measurement_send(&amp;amp;m_hts, &amp;amp;simulated_meas);

        switch (err_code)
        {
            case NRF_SUCCESS:
                // Measurement was successfully sent, wait for confirmation.
                NRF_LOG_INFO(&amp;quot;Measurement was successfully sent, wait for confirmation.\r\n&amp;quot;);
                m_hts_meas_ind_conf_pending = true;
                break;

            case NRF_ERROR_INVALID_STATE:
                // Ignore error.
                NRF_LOG_INFO(&amp;quot;Measurement has invalid state.\r\n&amp;quot;);
                break;

            default:
                **APP_ERROR_HANDLER(err_code);**
                break;
        }
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;highlighted the error with **&lt;/p&gt;
&lt;p&gt;It seems to me I fixed this error.&lt;/p&gt;
&lt;p&gt;I use adc to measure the temperature and I have a variable which has boolean values isConnected. I set true in this case&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_GAP_EVT_CONNECTED:
isConnected = true;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And every time when my data from adc is ready I check this variable, if it&amp;#39;s true, I send the new value.&lt;/p&gt;
&lt;p&gt;I guess I would send it before my services are initiated, and this error has come. I remove setting the value from line above and set it in this line&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_HTS_EVT_INDICATION_ENABLED:
isConnected = true;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now it works!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72001?ContentTypeID=1</link><pubDate>Mon, 02 Jan 2017 07:58:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1f0d02b-67b7-4930-950a-74dda103c80f</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. Have you been able to put a breakpoint in app_error_handler()? What is the line number, file name and error code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72000?ContentTypeID=1</link><pubDate>Fri, 30 Dec 2016 11:00:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26fbe57b-fe30-452d-987e-ee4d2c1407ee</guid><dc:creator>IlyaM</dc:creator><description>&lt;p&gt;I changed adc interrupt priority to 3 (the lowest priority) and It didn&amp;#39;t help, if I connect to ble in the same time when adc handler is activated I get error, if I connect earlier or later then adc is activated then everything is ok. I thought softdevice has the highest priority&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72002?ContentTypeID=1</link><pubDate>Fri, 30 Dec 2016 09:35:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:842fba6f-a134-4f76-84ac-af5b92064aa1</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I see that you are using interrupt priority 0, this is reserved for the SoftDevice and shouldn&amp;#39;t used. The application can use interrupt priority 1 or 3.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/71998?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 14:56:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba34bba1-5a9e-42ff-85af-06435b28838e</guid><dc:creator>IlyaM</dc:creator><description>&lt;p&gt;it returns NRF_SUCCESS and I see the value of conversion&lt;/p&gt;
&lt;p&gt;It seems adc interrupt correlates with BLE interrupts, cause when I increased the timer and connected to ble device before my adc handler interrupted I got working device&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/71999?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 14:22:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fa32f15-8988-4eb8-9381-4bf389733b6c</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;What does nrf_drv_adc_buffer_convert() return? NRF_SUCCESS (0x00000000)? Or an error? (PS. When using the SoftDevice you can use sd_app_evt_wait() instead of&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    __SEV();
    __WFE();
    __WFE();
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72003?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 14:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9da61565-a635-4da9-a48c-7796654882f0</guid><dc:creator>IlyaM</dc:creator><description>&lt;p&gt;I found the problem with this block&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void lmt70_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    NRF_LOG_INFO(&amp;quot;lmt70_timeout_handler\r\n&amp;quot;);
    /*APP_ERROR_CHECK(nrf_drv_adc_buffer_convert(adc_buffer, ADC_BUFFER_SIZE));
    for (uint32_t i = 0; i &amp;lt; ADC_BUFFER_SIZE; i++)
    {
        // manually trigger ADC conversion
        nrf_drv_adc_sample();
        // enter into sleep mode
        __SEV();
        __WFE();
        __WFE();
        nrf_delay_ms(100);
        NRF_LOG_FLUSH();
    }*/
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I leave this code commented, ble and timer work fine, if I remove comments I get this problem which described above.&lt;/p&gt;
&lt;p&gt;my ADC is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t ret_code;
    nrf_drv_adc_config_t config = NRF_DRV_ADC_DEFAULT_CONFIG;
    config.interrupt_priority = 0;

    ret_code = nrf_drv_adc_init(&amp;amp;config, lmt70_event_handler);
    APP_ERROR_CHECK(ret_code);

    channel1.config.config.input = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE;
    channel1.config.config.resolution = NRF_ADC_CONFIG_RES_10BIT;
    channel1.config.config.reference = NRF_ADC_CONFIG_REF_VBG;

    nrf_drv_adc_channel_enable(&amp;amp;channel1);
    timer_init();
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72006?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 12:17:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:423c904d-587e-40a8-a994-1adff49f0546</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Not app_error_save_and_stop(), but app_error_handler():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
{
    error_info_t error_info =
    {
        .line_num    = line_num,
        .p_file_name = p_file_name,
        .err_code    = error_code,
    };
    app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&amp;amp;error_info));

    UNUSED_VARIABLE(error_info);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72005?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 14:28:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e118a84-6fed-4004-86b0-7cfdd1ad478e</guid><dc:creator>IlyaM</dc:creator><description>&lt;p&gt;I use 12.2.0&lt;/p&gt;
&lt;p&gt;what I got via gdb&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(gdb) bt
#0  0x0001bd6a in app_error_save_and_stop (id=1, pc=63332, info=0)
    at /Users/im/Dropbox/nRF51822/Unzipped/SDK/12.2.0/components/libraries/util/app_error.c:113
#1  0x0001bdaa in app_error_fault_handler (id=1, pc=63332, info=0)
    at /Users/im/Dropbox/nRF51822/Unzipped/SDK/12.2.0/components/libraries/util/app_error_weak.c:32
#2  0x000299c8 in softdevice_fault_handler (id=1, pc=63332, info=0)
    at /Users/im/Dropbox/nRF51822/Unzipped/SDK/12.2.0/components/softdevice/common/softdevice_handler/softdevice_handler.c:90
#3  &amp;lt;signal handler called&amp;gt;
#4  0x0000f766 in ?? ()
#5  0x0000f71c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + Timer</title><link>https://devzone.nordicsemi.com/thread/72004?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 14:18:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:028ec152-1226-44c7-8e4f-0a4854801f37</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;What SDK are you using? If you define DEBUG and put a breakpoint in app_error_handler(), what is the line number, file name and error code? You should turn of optimizations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>