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

RTC and sleep mode

Hi everyone,

I am developing a quick evaluation demo for a low-power sensor node which consists of the following steps:

- read a couple of GPIOs

- set advertising name based on their status and advertise for X amount of seconds

- Once advertising is done, setup RTC/ other timer to generate an interrupt after Y time

- Go to lowest sleep state while keeping the timer on

- Wake up and start the process again

Does anyone know how to do the last three steps? Note that this module may be put to sleep for weeks for the application.

I am using the S140 device.

Thank you all

Parents
  • I have been able to accomplish this (mostly). Unfortunately, as soon as I enable the RTC, my system restarts. Does anyone know why? I am using a mix of the ble blinky and rtc examples.

    My code:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <stdint.h>
    #include <string.h>
    #include "nordic_common.h"
    #include "nrf.h"
    #include "app_error.h"
    #include "ble.h"
    #include "ble_err.h"
    #include "ble_hci.h"
    #include "ble_srv_common.h"
    #include "ble_advdata.h"
    #include "ble_conn_params.h"
    #include "nrf_sdh.h"
    #include "nrf_sdh_ble.h"
    #include "nrf_sdh_soc.h"
    #include "boards.h"
    #include "app_timer.h"
    #include "ble_nus.h" // source for Nordic UART service
    #include "nrf_ble_gatt.h"
    #include "nrf_ble_qwr.h"
    #include "nrf_pwr_mgmt.h"
    #include "nrf_gpio.h" // library to drive GPIOs
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Confirmed. Something is asserting or returning an invalid error code in rtc_config()

    Am I doing something wrong? Ie. setting up timers twice, rtc conflicts

    I cannot debug to the best of my ability as I only have the dongle with me right now.

  • Hi Daniel

    The SoftDevice uses RTC0. Looking at the code it seems you are also trying to enable RTC0. 

    Can you try to change it to RTC1 or RTC2 and see if it works better?

    Best regards
    Torbjørn

  • Yes, that seems to do the trick. I changed it to use RTC2.

    I still see a current draw of about 5uA. Can I decrease this down further in this mode?

  • Hi Daniel

    Yes, 5uA sounds a bit hig. Depending on how much RAM you have enabled the system ON sleep current with RTC wakeup enabled should be in the 1.5-3.2 uA range. 

    Do you know how much RAM you have enabled, and which LF clock source you are using?

    Are you just using a standard DK, and do you have any custom hardware connected?

    How are you measuring the current consumption?

    Best regards
    Torbjørn

  • Hi, to answer your questions:

    I am using the dongle. I am measuring current between a battery and the nRF supply. I have changed the USB jumpers to do this. No other hardware connected.

    I do not think I am disabling any RAM. Not sure on how to do this. How can I check my LFCLK. 

    My code is all up there ^^

    Thanks

Reply
  • Hi, to answer your questions:

    I am using the dongle. I am measuring current between a battery and the nRF supply. I have changed the USB jumpers to do this. No other hardware connected.

    I do not think I am disabling any RAM. Not sure on how to do this. How can I check my LFCLK. 

    My code is all up there ^^

    Thanks

Children
  • Hi Daniel

    Do you also have an nRF52840 DK to test on, or do you only have the dongle?

    Most likely the dongle is less power optimized, but I would have to do some digging internally. 

    By default all the RAM is on in system ON idle mode, so most likely you are not disabling anything. 

    RAM can be disabled by using the sd_power_ram_power_set(..) function, as documented here and in chapter 5.3.7.22 on page 79 of the nRF52840_PS_v1.1

    According to the comments in your code internal LF clock is used, which is fine power wise. 

    Best regards
    Torbjørn

  • Hi there,

    I am working on disabling the RAM and have found the following:

    for (int i = 0; i < 8; i++) {
    sd_power_ram_power_set(i,
    (POWER_RAM_POWER_S0POWER_Off << POWER_RAM_POWER_S0POWER_Pos)
    | (POWER_RAM_POWER_S1POWER_Off << POWER_RAM_POWER_S1POWER_Pos)
    | (POWER_RAM_POWER_S0RETENTION_Off << POWER_RAM_POWER_S0RETENTION_Pos)
    | (POWER_RAM_POWER_S1RETENTION_Off << POWER_RAM_POWER_S1RETENTION_Pos));
    }

    However, I tried this and see no difference when it comes to the power consumption. Still around 5.5uA.

    Am I doing something wrong?

  • Hi Daniel

    Do you have an nRF52840 DK you can test on for reference?

    If not, can you send me the code so I can test it on my end?

    Best regards
    Torbjørn