Reg the sleep modes and its configuration or library requirements (#includes) for nRF52833

Hi, 

We are working on the nRF52833 in one of our Gateway applications. We want to keep our Gateway in deep sleep (System OFF) mode if it is not configured or On-boarded. And should be in wakeup sleep mode after the On-boarding. We need 2 wakeup mechanisms in our firmware as below.

1. Before Onboarding - Should be in deep sleep mode and should allow only the GPIO interrupt.

2. After Onboarding - Device should be in sleep mode and should be able wakeup with the timer interrupt or GPIO interrupt.

Development Environment: VS Code (NCS v2.5.1)

I found there are many tickets raised in this regard, but unable to understand that the explanations or solutions are not the same in the discussions.

I want to understand the function calls, project config and header files (#include) requirements for the sleep modes. Because I am unable to access the functions which were share in the other tickets.

Please help me with the sleep functions and its library requirements to use in my code to achieve the best sleep mode currents for the longer battery life.

Parents
  • Hello,

    Whenever you enter system off mode, whatever gpios you set up for interrupts before you went to system off will still be active. Note that all timers (LFCLK) will be stopped when entering system off mode. But what you would need is to enable GPIO interrupts before going to system off, as long as you are not onboarded.

    When you are onboarded, all you need to do is to make sure that you call k_sleep() in one of your threads. This will wake you up when the timer times out again. It will also wake up on GPIO interrupts if that happens before the timer runs out.

    Please look at our samples. You can refer to the peripheral_uart found in ncs\nrf\samples\bluetooth\peripheral_uart, which has a button handler (button_changed()) and a k_sleep() in it's main thread.

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks for your information. Somehow it is clear.

    I tried testing the sample code "peripheral_uart" and found the sample code is consuming around ~200uA even after commenting the LED and the BLE advertising logic. By default, the same code consuming the few mA if I use the sample code directly due to LED and the BLE advertising.

    I need few clarifications and help in these sleep modes.

    System OFF sleep mode:

    - Please help with the logic for this sleep mode and its dependent libraries and configurations. Advise if there is any sample code available for this. 

    We understood initializing the GPIO interrupt to wake up from this sleep mode.

    System ON sleep mode:

    As per your information, it seems the k_sleep() can do the system ON sleep in idle mode and allows the GPIO and timer interrupts to handle the application.

    - Is this k_sleep() alone can help in achieving the best sleep currents? Or do we need add any additional commands or functions to it?

    - There are 2 active UARTs in my application. Will they go into sleep in both the sleep modes? or do we need to make the UARTs sleep while entering into the sleep mode? Please advise.

    I am just sharing my application block diagram for your reference.

Reply Children
No Data
Related