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

nRF52840 peripheral_uart low power NCS 1.3.0

Hi,

I am working with nrf52840dk and using a peripheral_uart example from NCS v1.3.0. and the problem that I am currently having is that I cannot get it to low power. At the moment I have power consumption ~500nA and I suppose this is from UART and Jlink programming pins. 
In the previous release of NCS v1.2.0, I have managed to turn off UART with the Power Management module, but for some reason, this is not working in the new release. More about my previous development is in this issue: nRF52 NCS power consumption

A also noticed that on the master branch of ncs-sdk peripheral_uart example has changed a lot.

My question is what is the best way to configure peripheral_uart example to low power?

Best regards,
Vojislav. 

Parents Reply Children
  • Hi Amanda,

    Please let me as soon as you know. 

    Best regards,
    Vojislav

  • Hi Vojislav, 

    I got the information from the UART engineer:

    We changed it a lot because we want to simplify it a little and we switch from the UART to asynchonous UARTE, and there was a small change in UART driver but it seems like he disabled it. So it might be the Power Manager in Zephyr was modified. 

    --

    I have to check with Zephyr engineer, but he is out of the office. Please note that we are in the summer vacation period here in Norway, so it might take a bit longer to get to the bottom of this than expected, as staff during the month of July will be reduced. I'm sorry about the inconvenience, but please be patient. And I'll get back to you as soon as I hear something from the devs.

    -Amanda H.

  • Hi Amanda,

    Thank you for your feedback. Regarding UART what is your advice, should I switch to UARTE instead of UART? 
    When you get a response from Zephyr engineer, please let me know. 

    Best regards,
    Vojislav

  • Hi Vojislav, 

    Sorry for the delay. I was not able to contact that engineer until today. 

    When using asynchronous UART API, RX has to be disabled before the peripheral is disabled. So if we want to modify that example to turn of UART completely, first call uart_rx_disable, wait for UART_RX_DISABLED event and then turn of peripheral using power management API

    https://github.com/nrfconnect/sdk-nrf/commit/4d0745b7df3885df5fd005ba1d89883f12383bc0#diff-49065e7b9505e965d6c45b371c82d3b6R146

    In the NCS v1.3 peripheral_uart example, UART is reenabled immediately after disabling, for continuous transmission so this line would have to be modified. 

    -Amanda H.

  • Hi Amanda,

    I am back on this issue and still having problems with power consumption. My current setup is nrf52840dk and PPK on top. SB40 is cut and I am measuring current with nRF Connect Power Profiler APP. 

    My current profile looks like this:

    As you can see from the picture the average current between advertising packets is ~530uA. 

    My main file has:

    static void led_blink_thread(void)
    {
    	int    blink_status       = 0;
    	int    err                = 0;
    
    	LOG_INF("Starting Nordic UART service example\n");
    
    	// err = init_uart();
    	// if (err) {
    	// 	error();
    	// }
    	
    	int rc = STATS_INIT_AND_REG(smp_svr_stats, STATS_SIZE_32,
    	    "smp_svr_stats");
    
    	if (rc < 0) {
    		LOG_ERR("Error initializing stats system [%d]", rc);
    	}
    
    	/* Register the built-in mcumgr command handlers. */
    #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
    	rc = fs_mount(&littlefs_mnt);
    	if (rc < 0) {
    		LOG_ERR("Error mounting littlefs [%d]", rc);
    	}
    
    	fs_mgmt_register_group();
    #endif
    #ifdef CONFIG_MCUMGR_CMD_OS_MGMT
    	os_mgmt_register_group();
    #endif
    #ifdef CONFIG_MCUMGR_CMD_IMG_MGMT
    	img_mgmt_register_group();
    #endif
    #ifdef CONFIG_MCUMGR_CMD_STAT_MGMT
    	stat_mgmt_register_group();
    #endif
    #ifdef CONFIG_MCUMGR_SMP_BT
    	//start_smp_bluetooth();
    #endif
    #ifdef CONFIG_MCUMGR_SMP_UDP
    	start_smp_udp();
    #endif
    
    
    	configure_gpio();
    
    	bt_conn_cb_register(&conn_callbacks);
    
    	if (IS_ENABLED(CONFIG_BT_GATT_NUS_SECURITY_ENABLED)) {
    		bt_conn_auth_cb_register(&conn_auth_callbacks);
    	}
    
    	err = bt_enable(NULL);
    	if (err) {
    		error();
    	}
    
    	LOG_INF("Bluetooth initialized\n");
    	k_sem_give(&ble_init_ok);
    
    	if (IS_ENABLED(CONFIG_SETTINGS)) {
    		settings_load();
    	}
    
    	err = bt_gatt_nus_init(&nus_cb);
    	if (err) {
    		LOG_ERR("Failed to initialize UART service (err: %d)\n", err);
    		return;
    	}
    	
    	/* Initialize the Bluetooth mcumgr transport. */
    	smp_bt_register();
    
    	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd,
    			      ARRAY_SIZE(sd));
    	if (err) {
    		LOG_ERR("Advertising failed to start (err %d)\n", err);
    	}
    
    	/* using __TIME__ ensure that a new binary will be built on every
    	 * compile which is convient when testing firmware upgrade.
    	 */
    	LOG_INF("build time: " __DATE__ " " __TIME__);
    
    	// uart_irq_rx_disable(uart);
    	// device_set_power_state(uart, DEVICE_PM_OFF_STATE, NULL, NULL);
    
    
    	for (;;) {
    		dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
    		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
    	}
    }
    
    void ble_write_thread(void)
    {
    	/* Don't go any further until BLE is initailized */
    	k_sem_take(&ble_init_ok, K_FOREVER);
    
    	for (;;) {
    		/* Wait indefinitely for data to be sent over bluetooth */
    		struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data,
    						     K_FOREVER);
    
    		if (bt_gatt_nus_send(NULL, buf->data, buf->len)) {
    			LOG_ERR("Failed to send data over BLE connection\n");
    		}
    
    		k_free(buf);
    
    		if (rx_disabled) {
    			rx_disabled = false;
    			uart_irq_rx_enable(uart);
    		}
    	}
    }


    And my prj.conf:
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_0_NRF_FLOW_CONTROL=y
    CONFIG_SERIAL=n
    CONFIG_GPIO=y
    
    # Make sure printk is not printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    
    # Enable the NUS service
    CONFIG_BT_GATT_NUS=y
    
    # Enable bonding if one of this four is enabled the application wont build with mcuboot
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Required by the `taskstat` command.
    #CONFIG_THREAD_MONITOR=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_STAT_MGMT=y
    
    # Enable logging
    CONFIG_LOG=n
    
    # Low power
    CONFIG_SYS_POWER_MANAGEMENT=y
    CONFIG_SYS_POWER_DEEP_SLEEP_STATES=y
    CONFIG_SYS_PM_STATE_LOCK=y


    So I think I disabled uart and consumption is still high... Do you have an idea what to do?

    Best regards,

Related