<?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>Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66712/catch-advertising-timeout-in-main</link><description>Hi, 
 
 I would like to catch in main.c the nobody connect after advertising event via ADV_SET_TERMINATED. 
 
 I can see with breakpoint program jump into ble_advertising_on_ble_evt inble_advertising.c but once traeted, it doesn&amp;#39;t call the same function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 02 Nov 2020 11:04:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66712/catch-advertising-timeout-in-main" /><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/278030?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 11:04:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51c960a1-2ee8-4b18-8994-6db51417ffc0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the update, glad to hear the programming part working again. For other questions I&amp;#39;d prefer you post it in a new thread as we have already moved away from the original topic. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277993?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 09:38:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8ed7a98-56b5-46bc-9805-8f415d18a2f8</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Hi Vidar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s ok i can work again. i had to check an option and remove the ldo on vdd pin into my jlink programmer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now i&amp;#39;m using my Power Profile Kit to supply and analyse my power consumption.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I had some trouble at the begining with the fact that i was enter into sleep mode (32uA) , timer wake up and execute the callback ( communication with the sensors , setitng some io...) , but after this callback execution, impossible to enter into sleep mode and program doesn&amp;#39;t return to main. I don&amp;#39;t know what uC was executing, but consumption was 7mA but i can&amp;#39;t reach breakpoint into the&amp;nbsp;main loop.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After debugging, I found that issue comes from the fact&amp;nbsp;that one IO was set to&amp;nbsp;1 , and avoid to enter system&amp;nbsp;in low power... Strange because wake up is only allowed when pin30 rise from&amp;nbsp; to 1 ...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I also wanted to send 16bit buffer into my characteristic , but i had to manage by spliting into two byte because it was crashig when i tried to upload my uint16 table directly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have also reach the limit of the number of data into the service (256?) in three characeteristics.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now my systeme has all the feature i will work on imporving power consumption, but i create a new topics i think :) .&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277887?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 17:29:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30b2c642-0636-4e75-8d7f-c84245bf3e22</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Ok after replacing a mux that was ded on my custom production board, i can flash with nrfConnect programmer the four files with succes and the program run fine. I still have issue in debug mode with SES.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1604078687849v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I can connect to jlink, but i click on run degug, i get an error :&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1604078752267v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277881?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 16:34:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61897ce3-f239-468b-b726-a2c9e41f33b8</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;I&amp;#39;m using a jlink programmer like this :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1604074703524v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;it is connected to my nrf52833 via a custom production board. But recently i mak etwo times a short to gnd by accident because of a gnd debug wire that touch some voltage on the board so i wonder about something broken. This short has shutdown my laptop because of impact on USB i guess...&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I already ordered a new segeer programmer . For the moment i will come back on the developpement board i think ... &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;But i&amp;#39;m surprised because i was able to debug two or three times this morning but then, impossible.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The led of the jlink programme blink one time each second , with green color. Its seems to indicate&amp;nbsp;according to documentation&lt;/p&gt;
&lt;p&gt;GREEN, switched off for 10ms once per second J-Link heart beat. Will be activated after the emulator has been in idle mode for at least 7 seconds.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277803?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 12:35:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dead58ea-5bef-4747-a428-c4228be4c44b</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="Olfox"]does the systeme goes automatically to sleep ? [/quote]
&lt;p&gt;&amp;nbsp;You still have to call idle_state_handle() again after when the program execution returns back to your main loop.&lt;/p&gt;
[quote user="Olfox"]. I can connect with jlink commander[/quote]
&lt;p&gt;Jlink commander is too failing to connect to the target based on the log you posted. Can you describe the programming setup you use (connections, voltage, etc)? &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277788?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 11:46:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1189233d-6da8-42cb-b4fb-7dbd0fdf4d7d</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Yes tha&amp;#39;s exactly what i did and it works fine. After handler function is finished, does the systeme goes automatically to sleep ? I also have a proble with my jlink connexion now , i don&amp;#39;t know why, I have tried several boards always the same issue. I can connect with jlink commander but impossible with nordic tool like nrf Connect or SES. What is strange is taht i didn&amp;#39;t get error in the past.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;C:\Users\flo&amp;gt;nrfjprog --version&lt;br /&gt;nrfjprog version: 10.8.0&lt;br /&gt;JLinkARM.dll version: 6.82c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;J-Link&amp;gt;connect
Please specify device / core. &amp;lt;Default&amp;gt;: CORTEX-M4
Type &amp;#39;?&amp;#39; for selection dialog
Device&amp;gt;?
Please specify target interface:
  J) JTAG (Default)
  S) SWD
  T) cJTAG
TIF&amp;gt;S
Specify target interface speed [kHz]. &amp;lt;Default&amp;gt;: 4000 kHz
Speed&amp;gt;
Device &amp;quot;NRF52833_XXAA&amp;quot; selected.


Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
SWD speed too high. Reduced from 4000 kHz to 853 kHz for stability
Failed to power up DAP
InitTarget() start
InitTarget() end
InitTarget() start
InitTarget() end
InitTarget() start
InitTarget() end
Cannot connect to target.
J-Link&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/84583.Capture.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277745?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 08:44:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3a0e606-e5d2-49c1-92ce-d0fa080cd111</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;No worries. For wakeup I would suggest you set up a repeated app timer instance like most of our BLE examples do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/277639?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 14:32:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1970380-c28f-465b-8f69-6ce725a81912</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;... Sorry Vidar ... you are right it was the problem ... I was so focused on it that i didn&amp;#39;t see this obvious mistake !&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now next let&amp;#39;s go to the next feature to implement: wake up the system each two days with a timer to measure a sensor , log into ram ( that is always on because of my power management mode), and go back to sleep. So i should be able to wake my system on gpio OR eache two days with a timer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/275480?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 06:15:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:090a4660-3452-4cad-abfb-f612682f4109</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It looks like you are missing the two hyphens (&amp;#39;--&amp;#39;) in front of &amp;quot;app-boot-validation&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/275389?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 13:33:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:853d9910-51a8-4224-935b-b6c23a03a50e</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Ha could be great but it generate en error.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried to move the argument in each place but same result. I also tried to remove application version argument etc but i always have this error:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;fw_no_signed&amp;gt;nrfutil settings generate app-boot-validation NO_VALIDATION --family NRF52 --application ble_app_buttonless_dfu_pca10100_s113.hex --application-version 6 --bootloader-version 1 --bl-settings-version 2 settings.hex


Usage: nrfutil settings generate [OPTIONS] HEX_FILE
Try &amp;#39;nrfutil settings generate --help&amp;#39; for help.


Error: Got unexpected extra arguments (NO_VALIDATION settings.hex)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/275380?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 13:17:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:120925c4-ab3e-4d39-866f-9f8a27060e4c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Excellent! Regarding the CRC check, if you are on SDK 15.3.0 or later, you can disable it by specifying --app-boot-validation NO_VALIDATION when you generate the settings page.&lt;/p&gt;
&lt;p&gt;nrfutil settings generate help menu:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4774.pastedimage1602854200398v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/275291?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 08:56:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e12f237-9c97-4675-9df6-4903ebb6a658</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Ok, it is working fine !&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is it possible to disable check of CRC in secure bootloader during debug ? Else, i always have to build a new setting page with new hex built.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/275261?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 07:34:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cce6aa0d-9d86-437e-ae04-73ce43195d54</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes I see now I have implemented it, i try to run my software but i&amp;#39;m stuck with some configuration issue, i guess with settings page. I&amp;#39;m using softdevice s113, secure_bootloader_s113 to perform dfu that worked in the past ( ota worked, but i couldn&amp;#39;t flash by jlink cable anymore lol ).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I try to solve this and i come back to you to tell you if spinlock is working :) . Again, thanks Vidar for your support !&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273947?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2020 08:25:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:048998b9-1495-4c46-9828-26ab2539f487</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The event register is internal and not exposed to the CPU. To clear it you must call __WFE/sd_app_evt_wait(). This is the reason why sd_app_evt_wait() has to be called twice after servicing an application interrupt.&lt;/p&gt;
[quote user="Olfox"]imagine for any reason even after calling two times this function product doesn t enter into low power mode ...&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;This is why I suggested that you placed the &amp;quot;wait for event&amp;quot; call in a spinlock loop earlier.&amp;nbsp; You want to be sure the correct interrupt/event was triggered before you transition to the next state.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273678?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 09:34:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45b99c0a-61ed-404f-96b0-c03ba29e0ca8</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Thanks for the link.&lt;/p&gt;
&lt;p&gt;I have found the problem. As my software is based on sdk example, bsp function managing leds and button were called with timer. When i connected scope on debug sleep pin ,i have seen the uC going into sleep for around 0.3sec. Then I thought to someting linked to timer and i have found the leds stuff. So i have set LEDS_NUMBER to 0 and now i&amp;#39;m not waken by this anymore and product is sleeping as i want.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I should clean all the function linked to bsp button and leds to be sure it will not happen anymore.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m still not sure whitch register to look at to mastered the enable source of wake up, and i still don&amp;#39;t know why i have to call two times idle_state_handle function. I&amp;#39;m really afraid to put a mass production product without be sure of this. imagine for any reason even after calling two times this function product doesn t enter into low power mode ...&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273518?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 13:50:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99dba2e6-d4e6-4a61-97b5-3b6c5d441a34</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;__WFE will execute as a __NOP instruction after servicing an interrupt because the Event register will be set. Please take a look at the ARM documentation here for a more detailed explanation as to how this works: &lt;a href="https://developer.arm.com/documentation/ka001269/1-0/?search=5eec6e71e24a5e02d07b259a"&gt;https://developer.arm.com/documentation/ka001269/1-0/?search=5eec6e71e24a5e02d07b259a&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273515?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 13:42:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:220686c8-fa14-422c-92e0-44590ba7c8b8</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;The problem is that i can enter without issue in &lt;span&gt;System ON idle&lt;/span&gt;( what i call low power) the first time. But then , after advertsing timeout , i can&amp;#39;t. If you go deeper in the idle function you can see that __WFE is called into&amp;nbsp;nrf_pwr_mgmt_run so that&amp;#39;s not the issue i think.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think the source of the probleme is that somthing is blocking the possibility to enter into&amp;nbsp;&lt;span&gt;System ON idle mode. But what or how can i know which interupt service is not served to clear the flag i don&amp;#39;t know where to look in whitch register for example&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273478?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 12:03:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16803027-308b-4638-af19-e825fa70aa16</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;So the problem is that you have to call the &amp;quot;idle&amp;quot; function to enter System ON idle? I think the safest method may be to add a spinlock loop in this case. Something like this maybe:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static volatile bool m_acc_wakeup_triggered;

void acc_wakeup_callback()
{
    m_acc_wakeup_triggered = true;
    ...


int main(void)
{
    bool       erase_bonds;
    ret_code_t err_code;

  //  etat = START;

    for (;;)
    {
        switch (etat){

            ...

            case LOW_POWER:

                    NRF_LOG_INFO(&amp;quot;State Machine : LOW POWER&amp;quot;);


                    accel_goto_mode_power(MODE_LOW_POWER);    // attention si echec recommencer 
                  

                    while(!m_acc_wakeup_triggered)
                    {
                        __WFE();
                    }
                    
                    m_acc_wakeup_triggered = false;
               
                    //ZZZZZZZZZZ... Program sleep here, will continu after this comment on wake up

                     bma400_goto_mode_power(MODE_SLEEP);    

                    etat = EVENT_WAKE_UP_MOVE;

                    break;

                /**/case EVENT_WAKE_UP_MOVE:
                
                        NRF_LOG_INFO(&amp;quot;State Machine : WAKE UP on move!&amp;quot;);
                        etat = ADVERTISING;

                        break;

            case ADVERTISING:
                NRF_LOG_INFO(&amp;quot;State Machine : ADVERTISING...&amp;quot;);

                // Start execution.
                advertising_start(erase_bonds);


                etat = WAIT_USER_CONNECT_OR_TIMEOUT;
                NRF_LOG_INFO(&amp;quot;State Machine : Wait USER CONNECT or TIMEOUT...&amp;quot;);
                    break;

        /**/case WAIT_USER_CONNECT_OR_TIMEOUT:
          

                
                    break;

                      /**/case EVENT_USER_BLE_CONNECT:
                              NRF_LOG_INFO(&amp;quot;State Machine : CONNECTED&amp;quot;);
                             
                          
                              etat = INIT_SENSORS;
                              break;

                      /**/case EVENT_ADVERTISING_TIMEOUT:
                              NRF_LOG_INFO(&amp;quot;State Machine : ADVERTISING TIMEOUT&amp;quot;);
                          
                              etat = LOW_POWER; //nobody is connected go back to sleep
                              break;

            case INIT_SENSORS:

                   
               
                    start_timer();
  
                    
                    etat = RUN;
                    break;

            case RUN:
                    //Sensors are measured in their timer interrupt
                    break;

            case EVENT_USER_BLE_DISCONNECT:

                  
                    NRF_LOG_INFO(&amp;quot;State Machine : DISCONNECT&amp;quot;);

                    etat = LOW_POWER;
                    break;

        }//end switch machine d&amp;#39;etat
   }//end for infinite
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273169?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 09:37:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79a39b9d-493d-43e8-b99b-abbc62e659a5</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;I call it in the main already, in my state machine, so i guess timeout advertising as raised an interrupt flag that as not been cleared as you said. How to know which flag has been set ? I think i have the same the issue at the first low power entering, because i need to call two times&amp;nbsp;idle_state_handle();&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    bool       erase_bonds;
    ret_code_t err_code;

  //  etat = START;

    for (;;)
    {
        switch (etat){

            case START:

                 log_init();

                NRF_LOG_INFO(&amp;quot;State Machine : START!&amp;quot;);

                // Initialize the async SVCI interface to bootloader before any interrupts are enabled.
                err_code = ble_dfu_buttonless_async_svci_init();
                APP_ERROR_CHECK(err_code);

                timers_init();

                power_management_init();
                buttons_leds_init(&amp;amp;erase_bonds);
                ble_stack_init();
                peer_manager_init();
                gap_params_init();
                gatt_init();

                services_init();

                advertising_init(); //fle advertising init should be called after services init else error
                conn_params_init();


                // ACCEL INIT

                acceel_init_spi();
                accel_goto_mode_power(MODE_LOW_POWER);           

                err_code = nrf_drv_gpiote_init();
                APP_ERROR_CHECK(err_code);

                nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
                in_config.pull = NRF_GPIO_PIN_NOPULL;

                err_code = nrf_drv_gpiote_in_init(30, &amp;amp;in_config, in_pin_handler);
                APP_ERROR_CHECK(err_code);
                nrf_drv_gpiote_in_event_enable(30, true);

                    etat = LOW_POWER;
                    break;

            case LOW_POWER:

                    NRF_LOG_INFO(&amp;quot;State Machine : LOW POWER&amp;quot;);


                    accel_goto_mode_power(MODE_LOW_POWER);    // attention si echec recommencer 
                  

                    idle_state_handle();
                    idle_state_handle();    //why two times ? but it works...
               
                    //ZZZZZZZZZZ... Program sleep here, will continu after this comment on wake up

                     bma400_goto_mode_power(MODE_SLEEP);    

                    etat = EVENT_WAKE_UP_MOVE;

                    break;

                /**/case EVENT_WAKE_UP_MOVE:
                
                        NRF_LOG_INFO(&amp;quot;State Machine : WAKE UP on move!&amp;quot;);
                        etat = ADVERTISING;

                        break;

            case ADVERTISING:
                NRF_LOG_INFO(&amp;quot;State Machine : ADVERTISING...&amp;quot;);

                // Start execution.
                advertising_start(erase_bonds);


                etat = WAIT_USER_CONNECT_OR_TIMEOUT;
                NRF_LOG_INFO(&amp;quot;State Machine : Wait USER CONNECT or TIMEOUT...&amp;quot;);
                    break;

        /**/case WAIT_USER_CONNECT_OR_TIMEOUT:
          

                
                    break;

                      /**/case EVENT_USER_BLE_CONNECT:
                              NRF_LOG_INFO(&amp;quot;State Machine : CONNECTED&amp;quot;);
                             
                          
                              etat = INIT_SENSORS;
                              break;

                      /**/case EVENT_ADVERTISING_TIMEOUT:
                              NRF_LOG_INFO(&amp;quot;State Machine : ADVERTISING TIMEOUT&amp;quot;);
                          
                              etat = LOW_POWER; //nobody is connected go back to sleep
                              break;

            case INIT_SENSORS:

                   
               
                    start_timer();
  
                    
                    etat = RUN;
                    break;

            case RUN:
                    //Sensors are measured in their timer interrupt
                    break;

            case EVENT_USER_BLE_DISCONNECT:

                  
                    NRF_LOG_INFO(&amp;quot;State Machine : DISCONNECT&amp;quot;);

                    etat = LOW_POWER;
                    break;

        }//end switch machine d&amp;#39;etat
   }//end for infinite
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273151?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 09:07:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b34870c5-d482-4b8a-9b1a-39bb1ddb2780</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you call idle_state_handle() from your main loop instead? If not you should consider placing it inside a spinlock loop that doesn&amp;#39;t exit until the GPIOTE interrupt is triggered.&lt;/p&gt;
&lt;p&gt;idle_state_handle() may return immediately if you call it after servicing an interrupt because the internal event register is not cleared. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273147?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 08:57:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8f72f79-ac43-4380-8b1c-dfaa33b1602c</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m in system On to keep ram retention and clock because i should wake up every day. My system start, do all peripherals init, go in low power with&amp;nbsp;idle_state_handle(); called two time because first time it jump over i don&amp;#39;t know why.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then I wake up with GPIOTE ( accelerometer connected to one input pin). It toggle from low to high. Once wake up, nrf52833 start advertising. If nobody connect, it raise timeout event, and i call&amp;nbsp;idle_state_handle() to enter in low power, but it doesn&amp;#39;t work this time. It jump over the the function without going into low power mode.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How to know why it is impossible to enter into sleep mode ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the tips to use port event&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273137?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 08:46:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c596fec2-0a0b-4f71-aba0-1791d3fd236c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What kind of sleep are you trying to enter, System OFF or System ON. If it&amp;#39;s system ON I would just recommend calling idle_state_handle() from the main loop like we do in our SDK examples.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also noticed that you were using GPIOTE IN events. This increases the idle current in SYSTEM ON. You may consider using GPIOTE port events instead:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span&gt;nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true); // &amp;lt;-- Set to false to use low power PORT events. GPIOTE IN vs PORT event: &lt;a title="Sleep" href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/_tmp/nrf52833/autodita/CURRENT/parameters.i_sleep.html?cp=4_1_0_4_1_0_0"&gt;Sleep&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273042?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2020 16:16:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17e325fa-9124-4e52-8b9b-32fb3451e82f</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;After wake up , i did the test to come back again in low power and i can still wakeup with my accelerometre, so what is sure, is that advertising timeout event change the condition to go into low power again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/273039?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2020 15:47:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7724ca3-929c-40c8-8d4b-43f6223be601</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;I&amp;#39;m using a gpio to enter low power mode:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried to call again thi init sequence but it doesn&amp;#39;t allow to enter a second time in low power:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;                nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
                in_config.pull = NRF_GPIO_PIN_NOPULL;

                err_code = nrf_drv_gpiote_in_init(30, &amp;amp;in_config, in_pin_handler);
                APP_ERROR_CHECK(err_code);
                nrf_drv_gpiote_in_event_enable(30, true);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Catch advertising timeout in main</title><link>https://devzone.nordicsemi.com/thread/272996?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2020 13:21:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27531d7b-f860-4cc4-8138-6f76a26737ad</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Great that&amp;#39;s works i can reach the event in main.c now. I had also this feeling before to read your answer that program was stopped lol.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now i have a second issue: after advertising timeout, i set ma state machine to enter low power with the call 2time to function idle_state_handle();:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; case LOW_POWER:

                    NRF_LOG_INFO(&amp;quot;State Machine : LOW POWER&amp;quot;);
            
                    bma400_goto_mode_power(MODE_LOW_POWER);    // attention si echec recommencer 

                    idle_state_handle();
                    idle_state_handle();    //why two times ? but it works...
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From a power on sequence this go into low power mode works. But after timeout advertising, it jump over the two function wihtout going into low power mode.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there a link with the fact that we were in timeout advertising event previously may be ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you Vidar !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>