nrf9160 gpio interrupt low power setting

SDK 2.3.0

We have a custom board with a few GPIO connected to various interrupt sources (Button, sensor interrupts, power connection etc.)

We are experiencing here sleep current 70uA even after turning all the other peripherals and sensors off and leaving 2-3 interrupt sources configured.

What I am looking for help with is the lowest possible power interrupt setup.

Here are some settings in the board file as well as the code snippet:

int8_t configButtonInt(bool enable, bool detectOff)
{
  int err = 0;
  #ifdef DEBUG_PRINT_SENSOR
    printf("Enabling pinButtonPwr Int.\n");
  #endif

  gpio_pin_configure(gpio_dev, pinButtonPwr, GPIO_INPUT | GPIO_PULL_UP);

  // if (detectOff)
    err = gpio_pin_interrupt_configure(gpio_dev, pinButtonPwr, GPIO_INT_EDGE_BOTH );
  // else
  //   gpio_pin_interrupt_configure(gpio_dev, pinButtonPwr, GPIO_INT_LEVEL_LOW );
    
  if (err !=0)
  {
    #ifdef DEBUG_PRINT_SENSOR
      printf("FAIL - Button Int setup. error: 0x%08X\n", err);
		#endif
    return err;
	}

  gpio_init_callback(&gpio_button_cb, buttonIntCallback, BIT(pinButtonPwr));
  err = gpio_add_callback(gpio_dev, &gpio_button_cb);
  if (err != 0) {
    #ifdef DEBUG_PRINT_SENSOR
      printf("Failed - Button Int setup\n");
    #endif

    return err;
  }

  #ifdef DEBUG_PRINT_SENSOR
    printf("OK - Button Int setup\n");
  #endif

  return ERROR_SUCCESS;
}

here is the common.dts file:

gpiote: &gpiote {
	status = "okay";
	/*lte uart wake up*/
	//interrupts = <4 2>;
	// interrupts = <22 2>,<4 2>,<6 2>,<10 2>;
	/*12v detect
	interrupts = <6 NRF_DEFAULT_IRQ_PRIORITY>;
	/*power Button*/
	// interrupts = <4 4>;
	/*acc int
	interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;*/
};

gpio0: &gpio0 {
	status = "okay";
	sense-edge-mask = < 0xffffffff >;
	// sense-edge-mask = < 0xffffffff >;
};

Parents
  • Hi,

    Could you make sure that you do not have any floating GPIO input pins which can cause current increase?

    Also, in case you do not use logging, please disable it.

    Regards,

    Priyanka

  • Hi Priyanka,

    logging should be disabled.

    Here is the prj.conf file :

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    
    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_NANO=n #disable for 64-bit long long support
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    CONFIG_HW_STACK_PROTECTION=y #added on 2023-11-24 to detect stack overflow
    
    CONFIG_PM=y
    # # Required to disable default behavior of deep sleep on timeout
    CONFIG_PM_DEVICE=y
    CONFIG_PM_DEVICE_RUNTIME=y
    
    #to implement our own error handler so we can store critical data before rebooting
    CONFIG_RESET_ON_FATAL_ERROR=n
    #dont halt but reset the system on panic
    CONFIG_TFM_HALT_ON_CORE_PANIC=n
    
    # Main
    CONFIG_NCS_SAMPLES_DEFAULTS=n
    #we want to be able to reboot
    CONFIG_REBOOT=y
    CONFIG_FPU=y
    # CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
    # CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=2
    #added on 2023-11-27 to deal with ENOMEM error on mqtt connect
    #after mqtt send returns -11 
    CONFIG_NRF_MODEM_LIB_HEAP_SIZE=4096 
    CONFIG_NRF_MODEM_LIB_SENDMSG_BUF_SIZE=4096
    CONFIG_POSIX_MAX_FDS=10
    CONFIG_NET_BUF_RX_COUNT=32
    CONFIG_NET_BUF_TX_COUNT=32
    CONFIG_NET_PKT_RX_COUNT=16
    CONFIG_NET_PKT_TX_COUNT=16
    
    CONFIG_HEAP_MEM_POOL_SIZE=12288
    
    # When the initialization is complete, the thread executing it then
    # executes the main() routine, so as to reuse the stack used by the
    # initialization, which would be wasted RAM otherwise.
    # After initialization is complete, the thread runs main().
    CONFIG_MAIN_STACK_SIZE=18432
    
    #This option specifies the size of the stack used by interrupt service routines (ISRs),
    # and during kernel initialization.
    CONFIG_ISR_STACK_SIZE=4096
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=12288
    
    #Watchdog
    CONFIG_WATCHDOG=y
    
    # Following 2 are added to avoid k_timeout_t error
    # CONFIG_LEGACY_TIMEOUT_API=y
    CONFIG_DATE_TIME=y
    
    #nrfx drivers
    #set all to no for power measurement
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    
    
    # ---------------------------------------------------------------
    # ---------------------------------------------------------------
    # choose one of these based on requirements
    
    # 1 ------------for power saving---------------------------------
    #comment these for power saving
    CONFIG_STDOUT_CONSOLE=n
    CONFIG_UART_CONSOLE=n
    # Segger RTT
    CONFIG_USE_SEGGER_RTT=n
    CONFIG_RTT_CONSOLE=n
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_LOG_BACKEND_UART=n
    
    
    
    # # for Logging
    CONFIG_LOG_BACKEND_RTT=n  #change to y for RTT
    CONFIG_LOG=n #change to y for RTT
    # # CONFIG_LOG_MODE_IMMEDIATE=y
    CONFIG_NET_LOG=n
    # # CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y
    CONFIG_NET_HTTP_LOG_LEVEL_DBG=y
    
    
    CONFIG_THREAD_NAME=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    
    #Zephyr http api - sockets
    CONFIG_HTTP_CLIENT=y
    
    # SMS
    CONFIG_SMS=y
    
    # nRF modem library
    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_NRF_MODEM_LIB_SYS_INIT=n
    CONFIG_MODEM_INFO=y #for nrf temperature
    CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y #lets application define a modem fault handler  https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/modem/nrf_modem_lib/nrf_modem_lib_fault.html
    
    # LTE link control
    #use 60 seconds timeout
    CONFIG_LTE_NETWORK_TIMEOUT=90
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    #for china
    CONFIG_LTE_NETWORK_MODE_LTE_M=y
    
    #Bands
    CONFIG_LTE_LOCK_BANDS=y
    # BANDS FOR US/CAN: 2, 4, 5, 12, 13, 17, 25, 26. BANDS FOR CHINA: 8
    # BANDS FOR CHILE: 3, 5
    # Turkey Bands: 3,7,8, 20
    CONFIG_LTE_LOCK_BAND_MASK="11000000010001100000011010"
    CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS=y
    #psm
    
    
    #001 - 1 hours       00001 (1) = 1 hours, 01010 = 10 hours, 00110 = 6 hours, 11010 = 26 hours
    CONFIG_LTE_PSM_REQ_RPTAU="00100110"
    #000 - 2 second      00001 (2) = 2 seconds on time, 00011 = 6 second on time
    CONFIG_LTE_PSM_REQ_RAT="00000011"
    
    # Library for buttons and LEDs
    CONFIG_DK_LIBRARY=n
    
    #flash with nvs
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
    
    # Image manager
    CONFIG_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    # FOTA library
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
    
    # Download client
    CONFIG_DOWNLOAD_CLIENT=y
    # CONFIG_DOWNLOAD_CLIENT_TLS=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_2048=y
    CONFIG_NET_SOCKETS_TLS_SET_MAX_FRAGMENT_LENGTH=n
    # DFU Target
    CONFIG_DFU_TARGET=y
    
    # Modem key management
    CONFIG_MODEM_KEY_MGMT=y
    
    # Application Upgrade support
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # MQTT
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=y 
    
    #17 minutes, in seconds
    CONFIG_MQTT_KEEPALIVE=1020
    CONFIG_MQTT_CLEAN_SESSION=n
    CONFIG_MQTT_TLS_SESSION_CACHING=y
    
    # GPIO
    CONFIG_GPIO=y
    
    # ADC
    CONFIG_ADC=y
    CONFIG_ADC_NRFX_SAADC=y
    CONFIG_ADC_ASYNC=n
    
    CONFIG_I2C_NRFX=y
    CONFIG_I2C=y
    
    CONFIG_AT_MONITOR=y

Reply
  • Hi Priyanka,

    logging should be disabled.

    Here is the prj.conf file :

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    
    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_NANO=n #disable for 64-bit long long support
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    CONFIG_HW_STACK_PROTECTION=y #added on 2023-11-24 to detect stack overflow
    
    CONFIG_PM=y
    # # Required to disable default behavior of deep sleep on timeout
    CONFIG_PM_DEVICE=y
    CONFIG_PM_DEVICE_RUNTIME=y
    
    #to implement our own error handler so we can store critical data before rebooting
    CONFIG_RESET_ON_FATAL_ERROR=n
    #dont halt but reset the system on panic
    CONFIG_TFM_HALT_ON_CORE_PANIC=n
    
    # Main
    CONFIG_NCS_SAMPLES_DEFAULTS=n
    #we want to be able to reboot
    CONFIG_REBOOT=y
    CONFIG_FPU=y
    # CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
    # CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=2
    #added on 2023-11-27 to deal with ENOMEM error on mqtt connect
    #after mqtt send returns -11 
    CONFIG_NRF_MODEM_LIB_HEAP_SIZE=4096 
    CONFIG_NRF_MODEM_LIB_SENDMSG_BUF_SIZE=4096
    CONFIG_POSIX_MAX_FDS=10
    CONFIG_NET_BUF_RX_COUNT=32
    CONFIG_NET_BUF_TX_COUNT=32
    CONFIG_NET_PKT_RX_COUNT=16
    CONFIG_NET_PKT_TX_COUNT=16
    
    CONFIG_HEAP_MEM_POOL_SIZE=12288
    
    # When the initialization is complete, the thread executing it then
    # executes the main() routine, so as to reuse the stack used by the
    # initialization, which would be wasted RAM otherwise.
    # After initialization is complete, the thread runs main().
    CONFIG_MAIN_STACK_SIZE=18432
    
    #This option specifies the size of the stack used by interrupt service routines (ISRs),
    # and during kernel initialization.
    CONFIG_ISR_STACK_SIZE=4096
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=12288
    
    #Watchdog
    CONFIG_WATCHDOG=y
    
    # Following 2 are added to avoid k_timeout_t error
    # CONFIG_LEGACY_TIMEOUT_API=y
    CONFIG_DATE_TIME=y
    
    #nrfx drivers
    #set all to no for power measurement
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    
    
    # ---------------------------------------------------------------
    # ---------------------------------------------------------------
    # choose one of these based on requirements
    
    # 1 ------------for power saving---------------------------------
    #comment these for power saving
    CONFIG_STDOUT_CONSOLE=n
    CONFIG_UART_CONSOLE=n
    # Segger RTT
    CONFIG_USE_SEGGER_RTT=n
    CONFIG_RTT_CONSOLE=n
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_LOG_BACKEND_UART=n
    
    
    
    # # for Logging
    CONFIG_LOG_BACKEND_RTT=n  #change to y for RTT
    CONFIG_LOG=n #change to y for RTT
    # # CONFIG_LOG_MODE_IMMEDIATE=y
    CONFIG_NET_LOG=n
    # # CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y
    CONFIG_NET_HTTP_LOG_LEVEL_DBG=y
    
    
    CONFIG_THREAD_NAME=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    
    #Zephyr http api - sockets
    CONFIG_HTTP_CLIENT=y
    
    # SMS
    CONFIG_SMS=y
    
    # nRF modem library
    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_NRF_MODEM_LIB_SYS_INIT=n
    CONFIG_MODEM_INFO=y #for nrf temperature
    CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y #lets application define a modem fault handler  https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/modem/nrf_modem_lib/nrf_modem_lib_fault.html
    
    # LTE link control
    #use 60 seconds timeout
    CONFIG_LTE_NETWORK_TIMEOUT=90
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    #for china
    CONFIG_LTE_NETWORK_MODE_LTE_M=y
    
    #Bands
    CONFIG_LTE_LOCK_BANDS=y
    # BANDS FOR US/CAN: 2, 4, 5, 12, 13, 17, 25, 26. BANDS FOR CHINA: 8
    # BANDS FOR CHILE: 3, 5
    # Turkey Bands: 3,7,8, 20
    CONFIG_LTE_LOCK_BAND_MASK="11000000010001100000011010"
    CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS=y
    #psm
    
    
    #001 - 1 hours       00001 (1) = 1 hours, 01010 = 10 hours, 00110 = 6 hours, 11010 = 26 hours
    CONFIG_LTE_PSM_REQ_RPTAU="00100110"
    #000 - 2 second      00001 (2) = 2 seconds on time, 00011 = 6 second on time
    CONFIG_LTE_PSM_REQ_RAT="00000011"
    
    # Library for buttons and LEDs
    CONFIG_DK_LIBRARY=n
    
    #flash with nvs
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
    
    # Image manager
    CONFIG_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    # FOTA library
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
    
    # Download client
    CONFIG_DOWNLOAD_CLIENT=y
    # CONFIG_DOWNLOAD_CLIENT_TLS=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_2048=y
    CONFIG_NET_SOCKETS_TLS_SET_MAX_FRAGMENT_LENGTH=n
    # DFU Target
    CONFIG_DFU_TARGET=y
    
    # Modem key management
    CONFIG_MODEM_KEY_MGMT=y
    
    # Application Upgrade support
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # MQTT
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=y 
    
    #17 minutes, in seconds
    CONFIG_MQTT_KEEPALIVE=1020
    CONFIG_MQTT_CLEAN_SESSION=n
    CONFIG_MQTT_TLS_SESSION_CACHING=y
    
    # GPIO
    CONFIG_GPIO=y
    
    # ADC
    CONFIG_ADC=y
    CONFIG_ADC_NRFX_SAADC=y
    CONFIG_ADC_ASYNC=n
    
    CONFIG_I2C_NRFX=y
    CONFIG_I2C=y
    
    CONFIG_AT_MONITOR=y

Children
No Data
Related