Power consumption on UART when using CONFIG_UART_ASYNC_API

Hi!

Working on a BT peripheral device that will work in two modes depending on a runtime check at startup:

Sending data over BLE, running on battery (UART unused).

Sending data over UART, externally powered.

Currently this is running using NRF sdk 1.7.,1 and we are working on updating to 2.1.

During this update we see a higher power consumption when enabling the CONFIG_UART_ASYNC_API after the update in the first case (so UART is not used).

old SW using sdk 1.7.1:

UART-related config:

CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y

CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_LOG=n
CONFIG_LOG_BACKEND_UART=n

Devicetree:

&uart0 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    current-speed = <115200>;
    tx-pin = <20>;
    rx-pin = <22>;
    //rts-pin = <5>;
    //cts-pin = <7>;
};

Measured average consumption (after startup/connecting): 26.5 uA

New SW using SDK 2.1 without CONFIG_UART_ASYNC_API:

UART-related config:

CONFIG_PINCTRL=y
CONFIG_NRFX_UARTE0=y
CONFIG_UART_NRFX=n
#CONFIG_UART_ASYNC_API=y

CONFIG_CONSOLE=n
CONFIG_LOG=n

CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_LOG_BACKEND_UART=n

Devicetree:

&uart0 {
compatible = "nordic,nrf-uarte";
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
};

Devicetree-pincontrol:

	uart0_default: uart0_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 20)>,
				<NRF_PSEL(UART_RX, 0, 22)>;
		};
	};

	uart0_sleep: uart0_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 20)>,
				<NRF_PSEL(UART_RX, 0, 22)>;
			low-power-enable;
		};
	};

Measured average consumption (after startup/connecting): 25.2 uA

New SW using SDK 2.1 with CONFIG_UART_ASYNC_API:

Also require to remove CONFIG_UART_NRFX=n

Devicetree wasn't changed from case above.

CONFIG_PINCTRL=y
CONFIG_NRFX_UARTE0=y
#CONFIG_UART_NRFX=n
CONFIG_UART_ASYNC_API=y

CONFIG_CONSOLE=n
CONFIG_LOG=n

CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_LOG_BACKEND_UART=n

Measured average consumption (after startup/connecting): 45.9uA

In this case adding a call to rx_disable changes the consumption very little.

Can you see any problem in our configuration?

Can you provide any support on how to configure it to bring the consumption down in the same range as for the old sdk but still be bale to use the async api?

Is there anything else we can do to disable the uart in the case where we do not use it?

Tried configuring the uart gpio-s using GPIO api at startup in the case when not using it, this doesn't seem to be possible.

Is there any way to completely turn off or disable UART in runtime or have it as disabled in the devicetree and enable it in runtime?

BR,

Mårten

  • Hello Mårten,

    A comment first. What is the point of setting CONFIG_SERIAL=n and CONFIG_UART_ASYNC_API=y. Setting CONFIG_SERIAL=n will make CONFIG_UART_ASYNC_API disable it/make it unavailable.

    You can see this in the file zephyr/drivers/serial/Kconfig. The Kconfig UART_ASYNC_API is within "if SERIAL" and  "endif # SERIAL"

    I also tested this with blinky

    • Setting CONFIG_SERIAL=y and CONFIG_UART_ASYNC_API=y in zephyr/samples/basic/blinky/prj.conf lead to CONFIG_UART_ASYNC_API=y and 
      CONFIG_SERIAL=y in blinky/build/zephyr/.config
    • Setting CONFIG_SERIAL=n and CONFIG_UART_ASYNC_API=y in zephyr/samples/basic/blinky/prj.conf lead to CONFIG_UART_ASYNC_API not being visible and CONFIG_SERIAL=n in blinky/build/zephyr/.config and the following build warning

    warning: UART_ASYNC_API (defined at drivers/serial/Kconfig:66) was assigned the value 'y' but got
    the value 'n'. Check these unsatisfied dependencies: SERIAL_SUPPORT_ASYNC (=n), SERIAL (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_ASYNC_API and/or look up
    UART_ASYNC_API in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.

    Isn't it better to set both of these option to "y", and enable UART fully in both the device tree and through Kconfig, and rather disable it during runtime, which I explain below how to achieve.

    Is there any way to completely turn off or disable UART in runtime or have it as disabled in the devicetree and enable it in runtime?
    Is there anything else we can do to disable the uart in the case where we do not use it?

    Try using pm_device_action_run(). See https://devzone.nordicsemi.com/support-private/support/292419#permalink=776526.

    Best regards,

    Simon

  • Hi!

    Solved, a previous mistake/test manged to hide the problem that config_serial was not set properly (or at least that I did not notice it).

    Now it works and with the expected consumption.

    BR,
    Mårten

Related