Pressing button fast leads to 20uA current consumption in system_on sleep mode.

Hello,

I use nRF52832 and SDK 17.02.

I use app_button library to detect and handle button pressing.

Everything works fine except that I have a testcase that is to press the button very fast like 2~3 times per second.

After handling the button event, it should get into the SYSTEM_ON sleep mode, which is about 2uA current consumption, which is normal for slow speed button pressing.

However, when pressing the button very fast, then when the system gets into SYSTEM_ON sleep mode, it can get higher current consumption, about 20uA.

I wonder what caused the 20uA current? 20uA seems to be some peripherals is enabled during the sleep, I wonder if it is GPIOTE in app_button?

Is it possible that the button_event_handler got nested entered, and something went wrong?

One more thing: I didn't use the external 32KHz LF clock, I used the internal 32KHz RC clock in this case.

Have you encountered the same problem? or if you have any ideas please share with me.

Thank you.

Jiayan

Parents Reply
  • gilbertjuly said:
    I'd like to upload screenshots and example project, but it needs a external storage space link?

     
    Zip the project, and upload it like this:

     

    gilbertjuly said:
    Another question is: how could I clear EVENTS_COMPARE[0] register in my code? Thank you.

     The driver already does this. In app_timer2.c -> rtc_irq ->drv_rtc_compare_pending -> evt_pending -> nrf_rtc_event_clear()

Children
  • hi, attached is the example project:

    The test environment is SDK 17.02.

    The test case is:

    1. Test the system-on sleep current consumption. 

    2. The code has three buttons, press any button very fast, like 3 times per second.

    3. After the CPU gets into system-on sleep again, test sleep current consumption.

    In step 3, we can find it has 20uA additional current consumption compared with step 1.

    I don't have a DK, regarding the key circuit, my board is designed like this:

    I attempted to debug, what I have found is: the CPU gets into SYSTEM ON sleep while the EVENTS_COMPARE[0] register of RTC1 (app_button's timer) is set. Attached is the KEIL register viewer during code running at "wait for event".

    I hope you can reproduce this. Thank you in advance.

    Jiayan

  • Hi,

    gilbertjuly said:

    I hope you can reproduce this. Thank you in advance.

    Update: I reproduced it on a DK. Looks like m_pin_active in app_button.c is stuck high, and the m_detection_delay_timer keeps getting started each time it times-out. I have not found a fix yet.

  • Please let me know once you have a way to fix it. Thank you.

  • Hi,

    Most likely the app_button module missed some pin state events, and got into this bad state. If your application have very fast button changes, a solution could be to use high accuracy mode instead(GPIOTE IN_event). Set BUTTON_HIGH_ACCURACY_ENABLED 1 in sdk_config. Note that this mode requires and uses a bit more current.

    #if defined(BUTTON_HIGH_ACCURACY_ENABLED) && (BUTTON_HIGH_ACCURACY_ENABLED == 1)
                static app_button_cfg_t buttons_cfgs[] =
        {
        {PIN_BUTTON_POWER, APP_BUTTON_ACTIVE_LOW, true, NRF_GPIO_PIN_PULLUP, button_event_handler},
    		{PIN_BUTTON_INCRESS, APP_BUTTON_ACTIVE_LOW, true, NRF_GPIO_PIN_PULLUP, button_event_handler},
    		{PIN_BUTTON_DESCRESS, APP_BUTTON_ACTIVE_LOW, true, NRF_GPIO_PIN_PULLUP, button_event_handler}
        };
    #else
                static app_button_cfg_t buttons_cfgs[] =
        {
        {PIN_BUTTON_POWER, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_event_handler},
    		{PIN_BUTTON_INCRESS, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_event_handler},
    		{PIN_BUTTON_DESCRESS, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_event_handler}
        };
    #endif //BUTTON_HIGH_ACCURACY_ENABLED

  • Hello,

    I have the same problem with the library app_button. Initially, in my custom board I have a consumption of 16 uA in the "Sleep state", after making some movement of the configured switches, when I return to the same "Sleep" position, it consumes 52 uA. I have tried to enable "BUTTON HIGH ACCURACY ENABLED" but the same thing happens. 

    Is there any other option that can be tried?

    Thank you very much.

Related