This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ble_advertising_start causes main to reset

I created a application that sometimes uses the BLE for 10 seconds. To turn on the BLE I'm using the function

ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);

and to turn off the BLE I'm using the function 

ble_advertising_start(&m_advertising, BLE_ADV_MODE_IDLE);

I already had the issue when I turned on the BLE the device would completely reset it self. I found this topic and this topic but the debugger is not throwing an exception. On a other topic that I can not find any more someone suggested to change the APP_ADV_DURATION definition to 0 what looks like is working for the start of the BLE.

But every time I'm calling the idle mode the device will reset itself without showing something on the debugger. At the moment I'm totally lost on what the solution could be.

Parents
  • Hi,

    Which SDK version are you using, and which example is your application based on?

    Did you set the DEBUG flag as described in the second link you posted? If the device is reset, something have usually put it iin the error handler. Please try setting a breakpoint in app_error_handler to see if the handler is called.

    Best regards,
    Jørgen

  • Hi Jørgen,

    Thank you for you reply! I'm currently running version 15.0.0 of the SDK and my application is based on the ble_app_template_pca10056_s140.

    I indeed set the debug flag and the console is only showing: <debug> nrf_sdh_ble: RAM starts at 0x20002B58 and when bluetooth is turned on: <info> app: Fast advertising.

    After that when I turn off the bluetooth it will just start again with <debug> nrf_sdh_ble: RAM starts at 0x20002B58 and the app_error_handler is not being called.

    I'm wondering if it has something to do with some sort of timeout because the APP_ADV_DURATION is causing them same reaction when starting the BLE.

    Edit 40 minutes later:

    I tried to reproduce the problem with the ble_app_uart (peripheral) example and when setting the APP_ADV_DURATION to 1000 (10 seconds) the system will throw a hardfault NRF_ERROR_NOT_SUPPORTED when that time is passed. This could be what is happening with my application to.

Reply
  • Hi Jørgen,

    Thank you for you reply! I'm currently running version 15.0.0 of the SDK and my application is based on the ble_app_template_pca10056_s140.

    I indeed set the debug flag and the console is only showing: <debug> nrf_sdh_ble: RAM starts at 0x20002B58 and when bluetooth is turned on: <info> app: Fast advertising.

    After that when I turn off the bluetooth it will just start again with <debug> nrf_sdh_ble: RAM starts at 0x20002B58 and the app_error_handler is not being called.

    I'm wondering if it has something to do with some sort of timeout because the APP_ADV_DURATION is causing them same reaction when starting the BLE.

    Edit 40 minutes later:

    I tried to reproduce the problem with the ble_app_uart (peripheral) example and when setting the APP_ADV_DURATION to 1000 (10 seconds) the system will throw a hardfault NRF_ERROR_NOT_SUPPORTED when that time is passed. This could be what is happening with my application to.

Children
  • I think that I found the problem but I do not know how to solve it.

    When I call the 

    ble_advertising_start(&m_advertising, BLE_ADV_MODE_IDLE);
     the system will eventually call 
    /**@brief Function for putting the chip into sleep mode.
     *
     * @note This function will not return.
     */
    static void sleep_mode_enter(void)
    {
        ret_code_t err_code;
    
        err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup buttons.
        err_code = bsp_btn_ble_sleep_mode_prepare();
        APP_ERROR_CHECK(err_code);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }
    
     and powering off the whole chip. When my RTC (or app_timer in this case) generates a interrupt the processor will wakeup and reset.

    In the datasheet I read that it is possible to retain some sections of RAM, for my application this is enough. Could you please point me to an example where RAM retention is used so I could implement this?

    Edit 4 minutes later:

    Well I spoke to soon, there is a RAM retention example called ram_retention (that is easy).

  • If your application is running in debug mode, you might enter the emulated system off state. When the return code from sd_power_system_off is checked, the application will reset. Please make sure you reset the board after programming, to make sure you are not in debug mode. If you want to debug, please remove APP_ERROR_CHECK after going to system off mode.

Related