<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68857/low-power-mode-in-zephyr</link><description>Hello, 
 I&amp;#39;m using zephyr to develop a battery powered IoT device with a sensor and a LoRa transceiver (SX126x). And I&amp;#39;m expecting to achieve average consumption values (during &amp;quot;sleep&amp;quot; mode) around ~15uA. At this moment I can only get ~360uA. I&amp;#39;ve already</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Jan 2021 12:44:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68857/low-power-mode-in-zephyr" /><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/290742?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2021 12:44:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:751f830c-aec9-4326-8276-67d3bc21f8ed</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;It looks like you have some leakage on the VDD domain since the base current between the spikes is so high. The varying current could be a floating GPIO input.&lt;/p&gt;
&lt;p&gt;I think we should first try to verify the measurement setup. If you put the chip to system OFF mode the chip will consume less than 1uA. If you still see a high current there will be other things connected to the VDD that consumes current, or you have leakage through the GPIOs (if configured as output). Make sure that the pins controlling the LoRa module are set to a defined level before entering system OFF mode so that the LoRa module does not consume current (typically the chip select pin).&lt;/p&gt;
&lt;p&gt;You said that you use the PPK in external mode, because of a shield. Does that mean that you are measuring on a DK? Which DK is this (PCA number and version)? Can you also please explain how you set up the PPK for measurements. If you connect the PPK directly to the external supply header on the DK you will be measuring the debugger on the DK as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/290710?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2021 10:56:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:039c3791-0939-4339-80dc-48bd1bb470bb</guid><dc:creator>diocorreia</dc:creator><description>&lt;p&gt;From my reading of the driver code, beside the SPI peripheral, the driver uses five GPIO pins: ANTENNA_ENABLE, TX_ENABLE, RX_ENABLE, RESET and DIO1. The first four pins are output pins, and are grounded during sleep. And the latter is an input pin, used by the LoRa board for callback.&lt;/p&gt;
&lt;p&gt;Here are the plots with the device&amp;#39;s current consumption, during sleep mode. The first plot shows the current consumption along all the sleep mode time. And, the second plot, is a zoomed view of the first one.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Screenshot-from-2021_2D00_01_2D00_21-17_2D00_31_2D00_54.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Screenshot-from-2021_2D00_01_2D00_21-17_2D00_36_2D00_21.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/290561?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 14:08:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:213660ac-7010-41e3-ba82-c32f0c6021f3</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi, I&amp;#39;m not familiar with the SX126x driver, so I think we first need to figure out which peripherals are active. As I&amp;nbsp; understand the communication protocol is SPI? The SPI should not consume any significant current unless it&amp;#39;s actively transmitting. Any other peripherals being used?&lt;/p&gt;
&lt;p&gt;Also the current consumption could be due to some polling feature in the LoRa driver. I recently had a case where a WiFi module driver was configured with a 1ms polling timer, which lead to a current consumption of 490 uA.&lt;/p&gt;
&lt;p&gt;If you are able to plot the current consumption you should be able to see if there are any timers waking up the CPU regularly (be aware that there will be spikes due to DCDC switching, but they should be distinguishable from the wakeup timers).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/288892?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2021 11:10:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30711a10-bd84-4a45-93cc-e82946e74a1d</guid><dc:creator>diocorreia</dc:creator><description>&lt;p&gt;Hi, Stian. No, I haven&amp;#39;t figured out how to solve this issue. Any idea?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/288779?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2021 22:05:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d414d89e-6687-4f28-a739-c4667053abed</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi, sorry for not getting back to you, I missed your last reply. Were you able to figure out this? Did you get any help from the Zephyr mailing list?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/284619?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 20:35:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:428b1f5f-bb51-4eee-ba24-7024eebef2c6</guid><dc:creator>diocorreia</dc:creator><description>&lt;p&gt;Having no success with my modifications on the driver. Tried to use the same method (device_set_power_state) with all GPIOs and the SPI device driver. When deactivating the first, nothing special appears to happen on the consumption. When I deactivate SPI, the consumption increases in the order of mA (guess is something related with the context loss that is described in zephyr documentation). Do you have any suggestion in how to address this issue? Or is it better to ask in zephy&amp;#39;s&amp;nbsp;mailing list?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Device Driver structure:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;struct sx126x_data {
	const struct device *reset;
	const struct device *busy;
	const struct device *dio1;
	struct gpio_callback dio1_irq_callback;
	struct k_work dio1_irq_work;
	DioIrqHandler *radio_dio_irq;
#if HAVE_GPIO_ANTENNA_ENABLE
	const struct device *antenna_enable;
#endif
#if HAVE_GPIO_TX_ENABLE
	const struct device *tx_enable;
#endif
#if HAVE_GPIO_RX_ENABLE
	const struct device *rx_enable;
#endif
	const struct device *spi;
	struct spi_config spi_cfg;
#if HAVE_GPIO_CS
	struct spi_cs_control spi_cs;
#endif
	RadioOperatingModes_t mode;
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
	uint32_t pm_state;
#endif
} dev_data;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;My PM function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef CONFIG_DEVICE_POWER_MANAGEMENT

static int sx126x_lora_pm_control(const struct device *dev, uint32_t ctrl_command,
				 void *context, device_pm_cb cb, void *arg)
{
	int ret = 0;
	struct sx126x_data *data = (struct sx126x_data *)dev-&amp;gt;data;

	switch (ctrl_command) {
	case DEVICE_PM_SET_POWER_STATE:
		if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
			data-&amp;gt;pm_state = DEVICE_PM_ACTIVE_STATE;
			device_set_power_state(data-&amp;gt;reset, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
			device_set_power_state(data-&amp;gt;busy, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
			device_set_power_state(data-&amp;gt;dio1, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
			#if HAVE_GPIO_ANTENNA_ENABLE
				device_set_power_state(data-&amp;gt;antenna_enable, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
			#endif
			#if HAVE_GPIO_TX_ENABLE
				device_set_power_state(data-&amp;gt;tx_enable, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
			#endif
			#if HAVE_GPIO_RX_ENABLE
				device_set_power_state(data-&amp;gt;rx_enable, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
			#endif
		} else {
			data-&amp;gt;pm_state = DEVICE_PM_OFF_STATE;
			device_set_power_state(data-&amp;gt;reset, DEVICE_PM_OFF_STATE, NULL, NULL);
			device_set_power_state(data-&amp;gt;busy, DEVICE_PM_OFF_STATE, NULL, NULL);
			device_set_power_state(data-&amp;gt;dio1, DEVICE_PM_OFF_STATE, NULL, NULL);
			#if HAVE_GPIO_ANTENNA_ENABLE
				device_set_power_state(data-&amp;gt;antenna_enable, DEVICE_PM_OFF_STATE, NULL, NULL);
			#endif
			#if HAVE_GPIO_TX_ENABLE
				device_set_power_state(data-&amp;gt;tx_enable, DEVICE_PM_OFF_STATE, NULL, NULL);
			#endif
			#if HAVE_GPIO_RX_ENABLE
				device_set_power_state(data-&amp;gt;rx_enable, DEVICE_PM_OFF_STATE, NULL, NULL);
			#endif
			ret = 0;
		}
		break;
	case DEVICE_PM_GET_POWER_STATE:
		*((uint32_t *)context) = data-&amp;gt;pm_state;
		break;
	default:
		ret = -EINVAL;
	}

	if (cb != NULL) {
		cb(dev, ret, context, arg);
	}
	return ret;
}
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */

#ifndef CONFIG_DEVICE_POWER_MANAGEMENT
DEVICE_AND_API_INIT(sx126x_lora, DT_INST_LABEL(0),
		    &amp;amp;sx126x_lora_init, NULL,
		    NULL, POST_KERNEL, CONFIG_LORA_INIT_PRIORITY,
		    &amp;amp;sx126x_lora_api);
#else
DEVICE_DEFINE(sx126x_lora, DT_INST_LABEL(0), &amp;amp;sx126x_lora_init,
	      sx126x_lora_pm_control, &amp;amp;dev_data, NULL, POST_KERNEL,
	      CONFIG_LORA_INIT_PRIORITY, &amp;amp;sx126x_lora_api);
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/284169?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2020 16:47:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c259319-1c6d-4c28-9d23-96f24a778910</guid><dc:creator>diocorreia</dc:creator><description>&lt;p&gt;No, I&amp;#39;m using an nRF52832.&lt;/p&gt;
&lt;p&gt;After some tests, I reached to the conclusion that the problem is probably in the LoRa module driver (sx126x) that is using GPIO and SPI without managing their power usage. I&amp;#39;ll try to modify the driver in order to optimize the power consumption.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power mode in Zephyr</title><link>https://devzone.nordicsemi.com/thread/282929?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2020 16:10:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2732eb0-f1b6-4fb6-95b1-0e307ba0d863</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi, are you using nRF52840? I have a feeling that the extra current is a result of UART1 being turned on. All UART instances are turned on by default in Zephyr.&lt;/p&gt;
&lt;p&gt;Create a file called nrf52840dk_nrf52840.overlay in the project root folder and add this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;uart1 {
    status = &amp;quot;disabled&amp;quot;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately there&amp;#39;s no easy way to see which devices are turned on in zephyr. Other than that I think your code looks good. The way you turn off logging (and hence UART0) looks fine:&lt;/p&gt;
&lt;p&gt;device_set_power_state(cons, DEVICE_PM_OFF_STATE, NULL, NULL);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]PS: these values were measured using the power profile kit in external mode due to the presence of a shield in the development board.[/quote]
&lt;p&gt;&amp;nbsp;How do you connect the PPK? If you are measuring on a nRF52 DK and power the DK thorugh the external supply header, the idle current is expected to be high because you power the debugger chip as well. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>