Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832 "ble_peripheral->ble_app_uart" stops working

Hello,

        I am trying to evaluate the "ble_app_uart" in the "nRF5_SDK" and I am using "DVK-BL652-SA-01" development board from LAIRD.

        The example works fine for a while. After some time, the application stops working. I can not even see the BLE device with my phone.

        What could be the problem ? Any idea ?

Best Regards

Parents
  • Hello,

    So you are in a connection while this happens, is that right?

     

    Can you please try to define "DEBUG" in your preprocessor defines, and set a breakpoint in the error handler in app_error.c. Exactly what line that is on depends on the SDK version. 

     

    Does the DVK from Laird come with an external LFXTAL, or does it use the RC Oscillator? If it uses the RC Oscillator, what settings have you used for it?

     

    Best regards,
    Edvin

  • Hello Edvin,

            I debug the code. When the code hits the "app_error_fault_handler" function, I get the register content below.

    <error> app: ERROR 8198 [Unknown error code] at E:\nRF5_SDK\examples\ble_peripheral\ble_app_uart\main.c:339
    PC at: 0x00033103
    <error> app: End of error report

    the "app_error_fault_handler" is called from the function above I think

  • How about Advertisement timeout. I can not find the below definition. Where can I find and modift it ?

    APP_ADV_TIMEOUT_IN_SECONDS

  • I didn't know what SDK version you used, so I gambled on the APP_ADV_TIMEOUT_IN_SECOND variable name. In SDK 15 this is called APP_ADV_DURATION, and is defined in units of 10ms. I guess it is defined as 18000 (=180s). 

     

    Yes. The sd_power_system_off() is a quite nice function, but it basically turns off the entire chip. A wakeup will be more or less like a reset, or power cycling the device. And also, you can't use e.g. the UART when you are in system off mode.

     

    There are a couple of ways to wake up from System_off mode. Either an interrupt on a GPIOTE pin, or alternatively, the NFC. Most of the ble_peripheral examples are set to wake up from a button press. You can play around with this by setting APP_ADV_DURATION to something short, like 2000 (=20sec), and see that it will turn off after 20 seconds, unless it has entered a connection. Then you can press one of the buttons, and see that it will start up again, and start advertising.

     

    However, you can not continue to send messages over the UART while in system off mode. It is intended as a deep sleep power saving mode for when the device is not in use, but can be turned back on with an interrupt from a GPIO or the NFC.

     

    Best regards,

    Edvin

  • Hello Edvin,

           I took a look at the "buttons_leds_init()" function. it works as you said. However, it is different from the link.

    in the link, the setup is something like below.

        nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true); 
        config.pull = NRF_GPIO_PIN_PULLUP;
        err_code = nrf_drv_gpiote_in_init(3, &config, pin_event_handler);
        nrf_drv_gpiote_in_event_enable(3, true);

    When I add the code above to my main code. it never wakes up the MCU ?

    Is there another think I need to do ? I assigned the pin "3" as the inturrupt pin. 

  • Remember that pin 3 is not one of the buttons on the DK, so you might have to try to toggle it with a cable. If you use pin 13 instead, it should be Button1 (button0), or if it is the nRF52840 that is in your module, it would be pin 11 that is button 1.

     

    If you look in e.g. the ble_app_hrs example, you will see in main.c, inside the on_adv_evt(...) function, inside the switch, case BLE_ADV_EVT_IDLE: sleep_mode_enter() is called.

    This again calls a function called bsp_btn_ble_sleep_mode_prepare(), which will enable two pins/buttons for wakeup. 

     

    I am not familiar with the DVK that you use, so you have to check the pin mapping, what pins/buttons the BTN_ID_WAKEUP and BTN_ID_WAKEUP_BOND_DELETE points to.

     

    Look at how the bsp_wakeup_button_enable() is implemented, or use it directly.

     

    Best regards,

    Edvin

  • I have modified the code and it now works well. Thanks a lot

    static void sleep_mode_enter(void)
    {
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup button.
        nrf_gpio_cfg_sense_set(3, NRF_GPIO_PIN_SENSE_LOW);
    
        // 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);
    }

Reply
  • I have modified the code and it now works well. Thanks a lot

    static void sleep_mode_enter(void)
    {
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup button.
        nrf_gpio_cfg_sense_set(3, NRF_GPIO_PIN_SENSE_LOW);
    
        // 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);
    }

Children
No Data
Related