<?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>Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71852/wake-up-sd_app_evt_wait-from-application</link><description>I am trying to keep everything synchronous between the client and peripheral. I am also try to make the peripheral code itself synchronous. So on the nRF51 DK, I use a button press to start advertising and then I enter the main loop which I have modified</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Mar 2021 18:16:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71852/wake-up-sd_app_evt_wait-from-application" /><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/302010?ContentTypeID=1</link><pubDate>Thu, 25 Mar 2021 18:16:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8935db71-34a2-4dff-b19e-bbe401242920</guid><dc:creator>ves</dc:creator><description>&lt;p&gt;I created a new ticket&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/73249/sd_app_evt_wait-behavior"&gt;devzone.nordicsemi.com/.../sd_app_evt_wait-behavior&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/302009?ContentTypeID=1</link><pubDate>Thu, 25 Mar 2021 17:52:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:064da922-66e5-493e-9a27-a157e190a2d5</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Turns out everything that is happening wakes up that method. In my case it was a periodic timer. However, there is no&amp;nbsp;information about what&amp;nbsp;the event is that wakes up the method. I just get a number that isn&amp;#39;t always the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/301993?ContentTypeID=1</link><pubDate>Thu, 25 Mar 2021 16:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa7172e3-89aa-41f4-b82a-1000761647f8</guid><dc:creator>ves</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have a similar issue but on different product 52832/s132&lt;/p&gt;
&lt;p&gt;Should i&amp;nbsp; raise another ticket (different product) or we can continue the discussion here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/298662?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 11:20:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b506d5f-4215-4b4c-a4ce-322f4d0a5ea6</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I see. We will try to improve our documentation.&amp;nbsp;&lt;br /&gt;If there isn&amp;#39;t any further question. I would suggest to close the case.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/298027?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 11:16:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c439f1ac-ede8-4a4f-9901-dea81add9d7c</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Hung,&lt;/p&gt;
&lt;p&gt;&amp;#39;Application event&amp;#39; is kind of vague. In fact, I have another thread posted asking just what is an application event? It may be obvious to the implementers of the SDK and SoftDevice but to outsiders, it&amp;#39;s not quite so clear, I first thought it was an event I could also define (thus application event) and could use to wake an efficient sleep much like a semaphore. (I guess that&amp;#39;s what I was hoping because I was looking for a way to emulate a semaphore.)&lt;/p&gt;
&lt;p&gt;Believe me, I have looked at as much documentation as I could find on this method! Just wish there was some more. Well for my app at least it controls everything.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/298007?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 10:38:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5d1ab0b-eabd-42ec-8d23-9aa23deeb6ea</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;br /&gt;If you read the description of the function&amp;nbsp;&lt;span&gt;sd_app_evt_wait() you get what the function is about:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;/**@brief Waits for an application event.&lt;/em&gt;&lt;br /&gt;&lt;em&gt; *&lt;/em&gt;&lt;br /&gt;&lt;em&gt; * An application event is either an application interrupt or a pended interrupt when the interrupt&lt;/em&gt;&lt;br /&gt;&lt;em&gt; * is disabled.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The app_timer (which is not part of the softdevice) is an application library and the interrupt it uses is RTC interrupt which is an application event. Any application event will wake up the chip from&amp;nbsp;sd_app_evt_wait(). What don&amp;#39;t wake up the chip from&amp;nbsp;sd_app_evt_wait() is BLE activities that the softdevice can handle on it own without involving the CPU/application.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/297826?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 13:40:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22037cf2-4957-4a1f-bb0c-0abc6c1bbc00</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Okay, that explains it. I have an app timer that is repeating fairly quickly. I understand that would wake up the CPU, but that does not mean sd_app_evt_wait() gets signaled. I did not know the app timer was part of SoftDevice; figured it was part of the RTC and had its own firmware. But okay, there is more that triggers sd_app_evt_wait() than I originally thought. Maybe more info in the docs about it? Perhaps most do not do what I am doing and handle sd_app_evt-wait() but use the SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/297755?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 11:06:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc5f9b33-e3bd-4e23-9cc6-b88fdb952fc0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;/p&gt;
[quote user="brianreinhold"] if I have a timer with a hundredth of a second interval and I start any timer (or just create that timer) that sd_app_evt_wait() will be woken up 100 times a second (at minimum)?[/quote]
&lt;p&gt;&amp;nbsp;I assume we are talking about app_timer here (the library), not the TIMER hardware or the RTC timer hardware. If you have a recurring app_timer of 1/100s then yes, it will wake the CPU up every 1/100s to handle the timer timeout. Without the CPU how can you handle an interrupt ?&amp;nbsp;&lt;br /&gt;By functionality I meant timer, or any CPU activity that you create in your application. If you have nothing but just initialize softdevice, enable BLE (no advertising) and a loop of&amp;nbsp;&lt;span&gt;sd_app_evt_wait() then the CPU shouldn&amp;#39;t wake up at all ( except for LFCLK calibration if you use RC).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/297441?ContentTypeID=1</link><pubDate>Wed, 03 Mar 2021 10:15:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d45865e-37cb-477f-a429-d81eae182dd5</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I guess my issue is trying to figure out what you mean by functionality. As soon as the chip has power there is all kinds of functionality that I cannot do anything about except turn it back off.&lt;/p&gt;
&lt;p&gt;When you say &amp;quot;&lt;span&gt;When you start the app timer, the interrupt interval will be the same as the shortest application timer interval you set.&amp;quot; does that mean if I have a timer with a hundredth of a second interval and I start any timer (or just create that timer) that sd_app_evt_wait() will be woken up 100 times a second (at minimum)? If that is so it is very important to know!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/297432?ContentTypeID=1</link><pubDate>Wed, 03 Mar 2021 10:01:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b81039a4-f68b-4d3a-97cd-cfc78e582e21</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I afraid I wouldn&amp;#39;t have any other idea other than turning off functionality and use logic trace to track the frequency of waking up to find what caused the issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The app timer uses a single RTC to handle timing. When you start the app timer, the interrupt interval will be the same as the shortest application timer interval you set.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296563?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 13:34:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05d81b5a-b12f-4a2a-a674-4c732f458bb3</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I don&amp;#39;t have much to play with. I have not started advertising yet so there are (or should be) no Bluetooth events. The only thing that has happened is the spin up to get the chip operational. I have to press a button to start Bluetooth.&lt;/p&gt;
&lt;p&gt;This is all I have and a lot of this is Nordic SDK stuff to initialize the chip.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int main(void)
{
    uint32_t err_code;
    unsigned char cccds[2];

    written = false;
    ghs_abort = false;
    send_live_data = false;
    first_cont_sent = false;
    numberOfStoredMsmtGroups = 0;
    memset(&amp;amp;storedSpot, 0, 30 * sizeof(s_MsmtData));

    // Initialize.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    spotGroupLength = 67;

    // Allocate memory for the security keys
    allocateMemoryForSecurityKeys(&amp;amp;keys);
    sec_params_init();
    timers_init();

    memset(&amp;amp;m_sccd_ghs_cp_handle, 0, sizeof(m_sccd_ghs_cp_handle));
    memset(&amp;amp;m_sccd_ghs_response_handle, 0, sizeof(m_sccd_ghs_response_handle));

    memset(cccds, 0, noOfCccds);
    loadKeysFromFlash(&amp;amp;keys, &amp;amp;saveDataBuffer, &amp;amp;saveDataLength, cccds, &amp;amp;noOfCccds);
    memcpy(cccdSet, cccds, noOfCccds);


    buttons_leds_init();

    gpiote_init_new();

    // This also provides the callback method to receive events.
    ble_stack_init();

    // Set device address
    ble_gap_addr_t addrStruct;
    addrStruct.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
    memcpy(addrStruct.addr, bluetoothAddress, 6);
    err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &amp;amp;addrStruct);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_DEBUG(&amp;quot;Could not set the Bluetooth Address\r\n&amp;quot;);
        APP_ERROR_CHECK(err_code);
    }
    // Sets max and min connection intervals, slave latency, and the GAP characteristic entries
    // for the friendly name and appearance.
    gap_params_init();
    // Creates the advertisement and scan response data arrays
    err_code = advertisement_ghs_set();
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_DEBUG(&amp;quot;Could not configure the advertisements\r\n&amp;quot;);
        APP_ERROR_CHECK(err_code);
    }
    // ===================================== Create the GHS service
    err_code = createPrimaryService(&amp;amp;m_sccd_ghs_service_handle, BTLE_SCCD_GHS_SERVICE);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_DEBUG(&amp;quot;Could not create GHS service\r\n&amp;quot;);
        APP_ERROR_CHECK(err_code);
    }
    // Create the GHS control point characteristic
    err_code = createStandardCharacteristic(m_sccd_ghs_service_handle,
        &amp;amp;m_sccd_ghs_cp_handle,
        BTLE_SCCD_GHS_CP_CHAR,
        true,   // Has CCCD
        true,   // This will cause indicate instead of notify if CCCD is set to true
        0,
        NULL,
        false,
        (ble_gap_conn_sec_mode_t) {1, 1},   // [CCCD write is open]
        (ble_gap_conn_sec_mode_t) {0, 0},   // Reading characteristic value is forbidden
        (ble_gap_conn_sec_mode_t) {1, 1});  // [Writing characteristic is open]
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_DEBUG(&amp;quot;Could not create GHS control point characteristic\r\n&amp;quot;);
        APP_ERROR_CHECK(err_code);
    }
    // ===================================== Create the GHS response characteristic
    err_code = createStandardCharacteristic(m_sccd_ghs_service_handle,
        &amp;amp;m_sccd_ghs_response_handle,
        BTLE_SCCD_GHS_RESPONSE_CHAR,
        true,   // Has CCCD
        false,  // This will cause indicate instead of notify if CCCD is set to true
        0,
        NULL,
        false,
        (ble_gap_conn_sec_mode_t)
        {
            1, 1
        },
        // CCCD write is open
        (ble_gap_conn_sec_mode_t)
        {
            0, 0
        },
            // Reading characteristic value is forbidden
        (ble_gap_conn_sec_mode_t)
        {
            1, 1
        });  // Writing characteristic is open
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_DEBUG(&amp;quot;Could not create GHS response characteristic\r\n&amp;quot;);
        APP_ERROR_CHECK(err_code);
    }
    // Not sure about this yet. I think it allows one to put up a fight to argue 
    // over connection parameters and sets up responses to connection parameter
    // change requests.
    conn_params_init();

    // Start execution.
    err_code = app_timer_start(m_app_dummy_timer_id, CMD_SENSOR_TIME, NULL);
    APP_ERROR_CHECK(err_code);
    elapsedTimeStart = app_timer_cnt_get();
    NRF_LOG_INFO(&amp;quot;GHS Pulse Ox Start at time %u!\r\r\n&amp;quot;, getTicks());
        
    //=============================================================================== Start GHS Pulse OX
    // Enter main loop.
    main_loop();
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Unless by initializing SoftDevice and the Buttons so I can press buttons and a single timer is causing these continuous wakeups. Would starting a timer of any type regardless of the frequency of repeats cause events at the rate of the RTC updates? I am not sure how all this hardware works.&lt;/p&gt;
&lt;p&gt;If it&amp;#39;s not Bluetooth related, I am pretty ignorant as to the possible causes. But I guess an easy first start is to comment out the dummy timer. If that does not change any behavior, I don&amp;#39;t really know where to go next.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296553?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 13:02:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81cd4c93-474b-4d5a-b7a8-bd57d4d64c3e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Please do what I suggested, turn off the functionality of the program until you see no waking up, and then turn them on one by one. You can start with disable any BLE functionality, no advertising.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296470?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 10:00:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc1bd233-29ee-4c2c-9254-ead81a5116fd</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Hung,&lt;/p&gt;
&lt;p&gt;I am less concerned about the value of the event (next time I ran it the event id was 26) but why is it waking up at such a high frequency? The only timer I am running before a DK button press is once a second. I have to have that timer in order to use the method&amp;nbsp;app_timer_cnt_get(). I had no idea that this method was being woken up at this high rate. It&amp;#39;s pretty important I understand why it is doing that as it will have a big impact upon my implementation. WIll it still behave like this when I put in on a chip and not the DK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296459?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 09:26:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8d19a61-f473-4109-a0f6-7285ef61ef84</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;br /&gt;I tried here and it show Soc event 0 continuously. I don&amp;#39;t know how you detect id 25.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But I would suggest to only print out &amp;quot;Soc event&amp;quot; only when the&amp;nbsp;err_code from&amp;nbsp;sd_evt_get() return NRF_SUCCESS.&amp;nbsp;&lt;br /&gt;If the chip is waking up from application&amp;#39;s interrupt it won&amp;#39;t have anything in sd_evt_get.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296282?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 13:40:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45090da8-4056-40ed-847e-bf975c3ef2f3</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I will give you the entire project. You will need the nrf51 DK and putty to view the log. Its a Keil project located here&lt;/p&gt;
&lt;p&gt;nrf_SDK_12.3.0\examples\ble_peripheral\ble_app_ghs_pleth\pca10028\s130\arm4&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrfSDK_5F00_12.3.0.zip"&gt;devzone.nordicsemi.com/.../nrfSDK_5F00_12.3.0.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Look at the method&amp;nbsp;&lt;/p&gt;
&lt;p&gt;static void power_manage(void)&lt;/p&gt;
&lt;p&gt;in main.c on line 1954.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296270?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 13:15:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db5d74ee-f504-4806-be8c-a7f08df4cac8</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I don&amp;#39;t know what could be soc evt id 25. Please provide a minimum code that can reproduce the issue so we can test here.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296181?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 09:44:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b6997b2-69ba-4c49-9366-b4b433868a57</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;That might be nice but all I have at my home is a volt meter and a soldering iron. For me the best chance of finding out what is going on is, perhaps, to just pull the event (I assume it only wakes up due to events) and print what the event is. All I did so far was to print a line of text after the wait was triggered and it came so fast it overflowed in less than a second. I might save some processing power by simply returning if it is not a ble or event that I actually handle somewhere in my loop.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I did print it out and used&amp;nbsp;sd_evt_get() to get the id of the event. The id is 25. And they are flying out at an incredible rate. The documentation says that it is an NRF_SOC_EVTS which is an enum containing only 9 events. &lt;span style="color:#0000ff;"&gt;What is event 25?&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296161?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 08:39:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ded6d756-8be2-4332-9cdf-6a17de4b194f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I would suggest to hook a logic analyzer and do the pin toggling as I did to check the interval of the waking up.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can try to test turn off functionalities of the application until you don&amp;#39;t see the waking up and then turn them back on to see what caused the waking up.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296022?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2021 13:02:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1a2b325-2217-422c-bcdf-66657d496c14</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Well as it turns out SOMETHING (I don&amp;#39;t know what) is waking it up all the time; its happening so fast NRF_LOG overflows. I don&amp;#39;t know what is waking it up at such a rate. Even before I start advertising this is happening. So&amp;nbsp; I can just set up the data and return in my timer callback and the wait will release. I don&amp;#39;t feel very good about that since I don&amp;#39;t know what is causing it. I am not intentionally causing those wakeups.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/296003?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2021 11:41:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d02e344c-8fa5-49e5-90a7-d10c633df51f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi again,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;sd_app_evt_wait() is called inside&amp;nbsp;idle_state_handle().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You should have same result if you have this in the main loop:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;for (;;)&lt;br /&gt; { &lt;br /&gt;&amp;nbsp;sd_app_evt_wait();&lt;br /&gt; &amp;nbsp;nrf_gpio_pin_toggle(28);&lt;br /&gt; }&lt;br /&gt;So what I want to show here is that every time you have a timer interrupt (or any application interrupt) and after you are done with the interrupt handler, the function right after&amp;nbsp;&lt;span&gt;sd_app_evt_wait() will be executed. This means the timer interrupt will wake the chip up from&amp;nbsp;sd_app_evt_wait().&amp;nbsp;&lt;br /&gt;The toggling of the pin, is just so that I can show you that the function is executed and the chip is waken up from&amp;nbsp;sd_app_evt_wait(). It can be any function.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You don&amp;#39;t need to send a dummy notification or anything to wake the chip up again.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/295994?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2021 11:08:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e527c74e-454a-4292-ac4d-0ec0bdfdc788</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Okay, then if I understand you correctly, it&amp;#39;s a little more complicated than just invoking a timer. I already invoke a periodic timer that when signaled calls a method to generate fake measurements. But it does NOT wake up sd_app_evt_wait(). Now what I want to do is wake up sd_app_evt_wait() after I generate the data.&lt;/p&gt;
&lt;p&gt;Its also not clear to me who is doing what your main loop. I assume the &amp;#39;idle_state_handle()&amp;#39; contains the wait? Maybe not? My main loop is waiting on sd_app_evt_wait(). It is not hiding in any method.&amp;nbsp; Are you saying that there is some method I can call from my timer handler that can toggle a pin on the chip that will release the wait?&lt;/p&gt;
&lt;p&gt;Below is the method my timer periodically calls. It generates fake data (it is simulating data coming from another MCU say via SPI or a UART). When generated I would like to wakeup the main loop and return and perform the &amp;#39;indicate_data()&amp;#39; from the main loop. But that I have been unable to do. So I call the method and that WILL wakeup the main loop eventually due to either the BLE_GATTS_EVT_HVC event or the BLE_TX_EVT_COMPLETE event. But doing so introduces asynchronous behavior - which I want to avoid at all costs.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void live_data_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    if (send_live_data)
    {
        live_data_count++;
        int i;
        unsigned long timeStamp32 = getTicks();
        NRF_LOG_DEBUG(&amp;quot;timestamp32 %lu\r\n&amp;quot;, timeStamp32);
        unsigned long long timeStamp = (unsigned long long)timeStamp32 * 1000;
        if (global_indicate.handle != 0)
        {
            NRF_LOG_DEBUG(&amp;quot;Not ready for measurement %lu at time %lu\r\n&amp;quot;, live_data_count, timeStamp32);
            return;
        }
        #if (HAS_PULSATILE == 1)
        liveMsmt.msmts.hasPulsatile = true;
        liveMsmt.msmts.pulsatile = 523 + (timeStamp32 &amp;amp; 0xFF);
        #else
        liveMsmt.msmts.hasPulsatile = false;
        #endif
        liveMsmt.msmts.spo2 = 95 + (timeStamp32 &amp;amp; 0x03);
        liveMsmt.msmts.pr = 45 + (timeStamp32 &amp;amp; 0x07);
        #if (HAS_PULSATILE == 1)
        NRF_LOG_DEBUG(&amp;quot;Measurement added: SpO2 %u%, PR %u, Pulsatile X 100 %u%, timestamp32 %lu, msmt count %lu\r\n&amp;quot;, 
            liveMsmt.msmts.spo2, 
            liveMsmt.msmts.pr, 
            liveMsmt.msmts.pulsatile, timeStamp32, live_data_count);
        #else
        NRF_LOG_DEBUG(&amp;quot;Measurement added: SpO2 %u, PR %u, timestamp32 %lu\r\n&amp;quot;, 
            liveMsmt.msmts.spo2, liveMsmt.msmts.pr, timeStamp32);
        #endif
        if ((live_data_count &amp;amp; 0x07) == 0x00)
        {
            NRF_LOG_DEBUG(&amp;quot;Spot msmt to send\r\n&amp;quot;);
            liveMsmt.hasTimeStamp = true;
            for (i = 0; i &amp;lt; 8; i++)
            {
                liveMsmt.relTime[i] = (unsigned char)(timeStamp &amp;amp; 0xFF);
                timeStamp = (timeStamp &amp;gt;&amp;gt; 8);
            }
            sendLiveSpotMeasurements(&amp;amp;liveMsmt);
        }
        else
        {
            sendLiveContinuousMeasurements(&amp;amp;liveMsmt);
        }
        indicate_data();  // Here is where I would like to wake up the main loop
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/295984?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2021 10:35:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8d45acb-45c3-4a69-8490-f44558d93410</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;br /&gt;I&amp;#39;m quite unsure I understand what you meant by &amp;quot;&lt;span&gt;Since I cannot wake up the sd_app_evt_wait()&amp;quot;. When you are in the timer interrupt handler you are already waking up (the CPU running) and you are out of the sd_app_evt_wait().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have made an example for you. This is modified from ble_app_hrs example.&amp;nbsp;&lt;br /&gt;I have this timer in my app:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt; &lt;em&gt;err_code = app_timer_start(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL, NULL);&lt;/em&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;With&amp;nbsp;BATTERY_LEVEL_MEAS_INTERVAL = 200ms.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then in my main loop I have this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt; for (;;)&lt;br /&gt; { &lt;br /&gt;&amp;nbsp; &amp;nbsp; nrf_gpio_pin_toggle(28);&lt;br /&gt;&amp;nbsp; &amp;nbsp; idle_state_handle();&lt;br /&gt;}&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;You can find the logic trace like this:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;&lt;em&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/689x84/__key/communityserver-discussions-components-files/4/pastedimage1614162870745v2.png" /&gt;&lt;br /&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This shows that the&amp;nbsp;nrf_gpio_pin_toggle(28) is called every time the battery timer timeout.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;So any application interrupt can wake up the chip from&amp;nbsp;&lt;span&gt;sd_app_evt_wait().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/295909?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 16:24:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9be3194-6bb1-482b-83d7-bbe89dfbecb8</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;How can I use a timer to wake up sd_app_evt_wait()? I am using the method as a way to emulate a semaphore. So when I get a measurement (say over a UART) I want to encode the measurement, set a flag, and wake up the loop. In the loop the &amp;#39;indicate_data()&amp;quot; method will be called and an MTU sized hunk of data will be indicated/notified. Then I exit the method and wait for a BTLE event.&lt;/p&gt;
&lt;p&gt;IN that manner, the only place I call the indicate_data() method is in that loop which keeps the flow synchronous.&lt;/p&gt;
&lt;p&gt;At the moment, I don&amp;#39;t have a real sensor so I fake measurements in a timer. Since I cannot wake up the sd_app_evt_wait() I simply call the indicate_data() method from the timer and return. That will cause a ble event. THe down side is that this introduces asynchrony as another event may wake up the loop and indicate_data() will be called from two places.&lt;/p&gt;
&lt;p&gt;Lousy non-robust solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up sd_app_evt_wait() from application</title><link>https://devzone.nordicsemi.com/thread/295898?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 15:58:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab803b13-a77a-44a7-8f8d-28a3d523caf1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When exactly you want to wake up from&amp;nbsp;&lt;span&gt;sd_app_evt_wait() ?&amp;nbsp;&lt;br /&gt;The&amp;nbsp;sd_app_evt_wait() only wake up when there is an BLE event or when there is an application event. It doesn&amp;#39;t let the application wake up if there is just an BLE event (with no data for example).&amp;nbsp;&lt;br /&gt;You can use the timer to periodically wake the&amp;nbsp;sd_app_evt_wait() up. If you simply want to go back to the top of the loop and can go through&amp;nbsp;sd_app_evt_wait() without waiting there, I think you can set a flag and not calling&amp;nbsp;sd_app_evt_wait() if the flag is set.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>