<?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>Coap Client SED low power</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97688/coap-client-sed-low-power</link><description>I am using: 
 nRF52840 NRF Connect SDK 1.9.1 Custom hardware 
 My project is based on the Coap Client example with mtd overlay added and is running in SED mode. I am using ot_coap_client_utils.c, so that I may send confirmable messages. 
 Using the PPK2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Mar 2023 16:44:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97688/coap-client-sed-low-power" /><item><title>RE: Coap Client SED low power</title><link>https://devzone.nordicsemi.com/thread/415552?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2023 16:44:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38aa452b-e88e-43df-b087-d272177506ef</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;Found it.&lt;/p&gt;
&lt;p&gt;This code puts the flash device in deep power down, then sets the CSn output high.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
#if (CONFIG_SPI_NOR - 0) ||				\
	DT_NODE_HAS_STATUS(DT_INST(0, jedec_spi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, jedec_spi_nor))
#define FLASH_NAME &amp;quot;JEDEC SPI-NOR&amp;quot;
#elif (CONFIG_NORDIC_QSPI_NOR - 0) || \
	DT_NODE_HAS_STATUS(DT_INST(0, nordic_qspi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, nordic_qspi_nor))
#define FLASH_NAME &amp;quot;JEDEC QSPI-NOR&amp;quot;
#elif DT_NODE_HAS_STATUS(DT_INST(0, st_stm32_qspi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, st_stm32_qspi_nor))
#define FLASH_NAME &amp;quot;JEDEC QSPI-NOR&amp;quot;
#else
#error Unsupported flash driver
#endif

#define QSPI_CS_DEVICE		DT_GPIO_LABEL(DT_NODELABEL(qspics), gpios)		
#define QSPI_CS_PIN			DT_GPIO_PIN(DT_NODELABEL(qspics), gpios)


void flash_low_power()
{
	const struct device *flash_dev;
	const struct device *cs_dev;

	flash_dev = device_get_binding(FLASH_DEVICE);

	pm_device_action_run(flash_dev, PM_DEVICE_ACTION_SUSPEND);

	cs_dev = device_get_binding(QSPI_CS_DEVICE);
	if (cs_dev == NULL) {
		printk(&amp;quot;Cannot bind gpio device\r\n&amp;quot;);
		//return -ENODEV;
		return;
	}
	
	int err = gpio_pin_configure(cs_dev, QSPI_CS_PIN, GPIO_OUTPUT);
	gpio_pin_set(cs_dev, QSPI_CS_PIN, 1);

}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Mary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap Client SED low power</title><link>https://devzone.nordicsemi.com/thread/415492?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2023 13:56:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5250ef7e-7594-498d-b9ec-1f66afd4f01d</guid><dc:creator>Mary</dc:creator><description>&lt;p&gt;I think most of the current is from the flash device, MX25R6435.&amp;nbsp; From other posts, I saw that the CSn must be configured as gpio output and set high, but it doesn&amp;#39;t come up that way.&amp;nbsp; I will eventually be using MCUBOOT, with externa flash as slot1.&lt;/p&gt;
&lt;p&gt;I created a &amp;quot;HelloWorld&amp;quot; but with this added to the prj.conf&lt;/p&gt;
&lt;p&gt;CONFIG_SERIAL=n&lt;br /&gt;CONFIG_PM=y&lt;br /&gt;CONFIG_PM_DEVICE=y&lt;/p&gt;
&lt;p&gt;I set the CSn as gpio output, and set it high.&amp;nbsp; I am now down to 121 uA, which is still too high, but there are some other devices I need to look into.&lt;/p&gt;
&lt;p&gt;About the QSPI flash...&lt;/p&gt;
&lt;p&gt;I tried adding this code to configure the CSn line.&amp;nbsp; Stepping into, then out of this function led to a odd place, where the call stack wasn&amp;#39;t as expected.&amp;nbsp; I ended up in nf_qspi_nor.c, in functions that I did not call.&amp;nbsp; I noticed that there is support for &amp;quot;Anomaly 122&amp;quot; there.&amp;nbsp; So, what is the proper way, using ncs, to put the flash in deep power down, then reawaken it when I need to use it?&amp;nbsp; I will only use it for OTA updates.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void flash_low_power()
{
	struct device *dev;
	// eratum 122
	// https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52840_Rev2%2FERR%2FnRF52840%2FRev2%2Flatest%2Fanomaly_840_122.html
	*(volatile uint32_t *)0x40029010ul = 1ul;
    *(volatile uint32_t *)0x40029054ul = 1ul;
    nrfx_qspi_uninit();

	dev = device_get_binding(QSPI_CS_DEVICE);
	if (dev == NULL) {
		printk(&amp;quot;Cannot bind gpio device\r\n&amp;quot;);
		//return -ENODEV;
		return;
	}

	
	int err = gpio_pin_configure(dev, QSPI_CS_PIN, GPIO_OUTPUT);
	gpio_pin_set(dev, QSPI_CS_PIN, 1);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here are the requested files.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/my_2E00_config"&gt;devzone.nordicsemi.com/.../my_2E00_config&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6320.zephyr.dts"&gt;devzone.nordicsemi.com/.../6320.zephyr.dts&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Mary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap Client SED low power</title><link>https://devzone.nordicsemi.com/thread/415472?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2023 13:28:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62fb376b-8138-40ff-b3d8-6b1d5d8e69a6</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you post the&amp;nbsp;.config file and the zephyr.dts file&amp;nbsp;that is generated in the build folder when you build the sample?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>