Deep sleep is only working in debugging and not without debugging

I am using nrf52811 in my PCB, and sdk version 16.00

I am encountering a challenge related to implementing deep sleep functionality, and as a beginner, I've been struggling to configure it correctly. Despite my best efforts, my device does not seem to enter sleep mode in its normal standalone operation. I've verified this by monitoring its current consumption, which remains nearly the same as in active mode.

CASE 1: STANDALONE

What happens is that the device disconnects from Bluetooth Low Energy (BLE), and I cannot reconnect it unless the device detects a low signal on GPIO pin 18.

CASE 1: DEBUGGING MODE

Additionally, when the device disconnects from BLE, I observe a fatal error in the debug terminal and receive an "ERROR 8 (0*8) GATT_CONN_TIMEOUT" message in the nrf_connect mobile app. The device remains in this state until it detects a low signal on GPIO pin 18.

I've been grappling with this issue for about 10 days now and haven't been able to pinpoint the root cause or find a solution. I've attached my code below for review, and I would appreciate it if someone could help me identify where I might be making a mistake.

Parents
  • Hello,

    Despite my best efforts, my device does not seem to enter sleep mode in its normal standalone operation. I've verified this by monitoring its current consumption, which remains nearly the same as in active mode.

    How many milliamps do you measure when the when the device is supposed to be in System OFF and with the debugger disconnected?

    CASE 1: STANDALONE

    What happens is that the device disconnects from Bluetooth Low Energy (BLE), and I cannot reconnect it unless the device detects a low signal on GPIO pin 18.

    The chip is powered down in System OFF mode ( deep sleep) and can only be woken up by external input events.

    CASE 1: DEBUGGING MODE

    You can't enter system OFF mode when you are in debug interface mode, see Emulated System OFF mode.

  • How many milliamps do you measure when the when the device is supposed to be in System OFF and with the debugger disconnected?

    14mA

    The chip is powered down in System OFF mode ( deep sleep) and can only be woken up by external input events.
    Yes you are right , but the device is not going to deep sleep as current consumption remains same, but i don't know  why BLE disconnects and device also doesn't advertise

    You can't enter system OFF mode when you are in debug interface mode, see Emulated System OFF mode.
    Yes you are right , but i just wanted to test the behavior in debugging mode and it was working fine in debugging mode
    How it can be possible

  • Pin 6 is assigned to the UART by default. Have you changed the pinout for the UART, or is it still using it?

  • No i have not changed it, do it need to be changed? 
    if yes how can i change it?

  • Hi Vidar Berg, 
    Thank you so much , this was the problem . Now I changed the pins of uart and the led is working precisely. 
    There is one problem left when the device goes in deep sleep mode it gives an error 8(0*8) GATT _CONN_TIMEOUT on nrf_Connect app. I tried to disconnect before going in deep sleep but this error presists . Other than gatt conn timeout the device goes to deep sleep and wakes up too should i just ignore it or is this can cause a problem

    From a resource i got to know that buy adding this in deep sleep function the error can go away,

    sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    
        while (m_conn_handle != BLE_CONN_HANDLE_INVALID)
        {
            // Poll the application scheduler to execute the main loop
            app_sched_execute();
        }
    yes by adding this device disconnects gracefully but it doesn't wake up 

  • I'm glad to hear that it's working now. If the peripheral turns off without properly terminating the connection, the central connection will time out. This means it will take longer for the central to detect that the connection has been lost.

    AIRAM said:
    From a resource i got to know that buy adding this in deep sleep function the error can go away,

    If the sleep function is called from an interrupt context, such as from the app timer callback, the program will never exit this while loop. This is because the Softdevice event that is supposed to clear the 'm_conn_handle' variable will become blocked. The simplest solution to this is to replace the while loop with a busy wait and hope the connection is successfully terminated after the delay.

    #include "nrf_delay.h"
    
    static void sleep_mode_enter(void)
    { 
        ...
        (void) sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
        /* Wait for connection to be terminated*/
        nrf_delay_ms(100);
        ...
        

  • Thank You so much Vidar Berg , it's working right, Now

Reply Children
No Data
Related