<?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>External flash to sleep</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114224/external-flash-to-sleep</link><description>My board (nrf52840 sense) has flash memory P25Q16H . When I put everything off, the board consumes 25uA. To save the last bit of current I would like to put the flash memory to deep sleep. 
 
 In the debugger, eventually this function in file nrf_qspi_nor</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Aug 2024 15:57:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114224/external-flash-to-sleep" /><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500465?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2024 15:57:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f770c7f-45de-4a6a-81b7-a80ffdf2fd01</guid><dc:creator>morgendagen</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;I can confirm that this also works on a non-Sense board using ncs 2.7.0.&amp;nbsp;Thank you so much for looking into this issue to both of you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Peder&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500418?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2024 12:09:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d55aca4a-8940-4b03-a1f9-e8321c79b3e1</guid><dc:creator>boris bergman1</dc:creator><description>&lt;p&gt;Yes thank you so much, I can confirm this works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500350?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2024 07:18:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d61b864c-5195-41b5-a16b-53b6ae99b770</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I looked at the devicetree for the XIAO BLE board and noticed that it disconnects all the QSPI pins, including CS, when the &amp;#39;sleep&amp;#39; state is applied:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/d32d4af935484b4de247a9f857dc90fb281f565e/boards/arm/xiao_ble/xiao_ble-pinctrl.dtsi#L99"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/d32d4af935484b4de247a9f857dc90fb281f565e/boards/arm/xiao_ble/xiao_ble-pinctrl.dtsi#L99&lt;/a&gt;. This will leave the CS input on the&amp;nbsp;P25Q16H floating, which I suspect may explain why it fails to enter/stay in power down mode.&lt;/p&gt;
&lt;p&gt;Please try to apply&amp;nbsp;the&amp;nbsp;DT overlay included the zip below to your build&amp;nbsp;and see if it helps:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/3302.xiao_5F00_ble_5F00_sense.zip"&gt;devzone.nordicsemi.com/.../3302.xiao_5F00_ble_5F00_sense.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500300?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 20:09:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a176dded-179a-43c3-bf23-7c6e0a2bd6dd</guid><dc:creator>boris bergman1</dc:creator><description>&lt;p&gt;I read that too, I&amp;#39;ll post his code for convenience.&lt;/p&gt;
&lt;p&gt;flash.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;nrfx_qspi.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;

#define QSPI_SCK_PIN    21
#define QSPI_CS_PIN     25
#define QSPI_IO0_PIN   20
#define QSPI_IO1_PIN    24
#define QSPI_IO2_PIN    22
#define QSPI_IO3_PIN    23

int da_flash_init()
{
    const struct device * dev = DEVICE_DT_GET(DT_NODELABEL(gpio0));
    if (!device_is_ready(dev))
    {
        return -ENODEV;
    }
    gpio_pin_configure(dev, QSPI_CS_PIN, GPIO_OUTPUT_HIGH);

    nrfx_qspi_config_t qspi_cfg =
    {
        .xip_offset = 0,
        .pins =
        {
            .sck_pin = QSPI_SCK_PIN,
            .csn_pin = QSPI_CS_PIN,
            .io0_pin = QSPI_IO0_PIN,
            .io1_pin = QSPI_IO1_PIN,
            .io2_pin = QSPI_IO2_PIN,
            .io3_pin = QSPI_IO3_PIN,
        },
        .prot_if = 
        {
            .readoc = NRF_QSPI_READOC_READ4O, // 0x6B read command
            .writeoc = NRF_QSPI_WRITEOC_PP4O, // 0x32 write command
            .addrmode = NRF_QSPI_ADDRMODE_24BIT,
            .dpmconfig = false
        },
        .phy_if =
        {
            .sck_delay = 10,
            .dpmen = false,
            .spi_mode = NRF_QSPI_MODE_0,
            .sck_freq = NRF_QSPI_FREQ_32MDIV16, // start with low 2 Mhz speed
        },
        .irq_priority = 7,
        .skip_gpio_cfg = true,
        .skip_psel_cfg = false
    };

    // No callback for blocking API
    nrfx_err_t err = nrfx_qspi_init(&amp;amp;qspi_cfg, NULL, NULL);
    if (err != NRFX_SUCCESS)
    {
        return -err;
    }

    return 0;
} 

void da_flash_uninit()
{
    nrfx_qspi_uninit();
}

int da_flash_command(uint8_t command)
{
    nrf_qspi_cinstr_conf_t cinstr_cfg = {.opcode = command,
                                         .length = NRF_QSPI_CINSTR_LEN_1B,
                                         .io2_level = true,
                                         .io3_level = true,
                                         .wipwait = false,
                                         .wren = false};

    nrfx_err_t err = nrfx_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, NULL);
    if (err != NRFX_SUCCESS)
    {
        return -err;
    }

    return 0;
}&lt;/pre&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;da_flash_init();
da_flash_command(0xB9);
da_flash_uninit();
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500281?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 18:41:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9aea13a3-f724-430c-baa3-adf398b4c22e</guid><dc:creator>morgendagen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am very interested in a fix for this issue as well.&lt;/p&gt;
&lt;p&gt;My situation is the same except I am using a non-Sense Xiao BLE: approximately 20uA if I do not do anything to power off the external flash, and 2mA if I&amp;nbsp;use&amp;nbsp;&lt;span style="font-family:verdana, geneva;"&gt;pm_device_action_run&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I did stumble upon a partial solution in this message:&amp;nbsp;&lt;a href="https://forum.seeedstudio.com/t/low-power-with-xiao-nrf52840-on-zephyr-rtos/270491/6"&gt;https://forum.seeedstudio.com/t/low-power-with-xiao-nrf52840-on-zephyr-rtos/270491/6&lt;/a&gt;. By adding &lt;span style="font-family:verdana, geneva;"&gt;flash.*&lt;/span&gt; from the zip-file linked to in the message &amp;nbsp;to my project and executing&amp;nbsp;&lt;span style="font-family:verdana, geneva;"&gt;da_flash_init(); da_flash_command(0xB9); da_flash_uninit();&lt;/span&gt;, the power consumption gets down to&amp;nbsp;2.5uA, which is in line with my expectations.&lt;/p&gt;
&lt;p&gt;So it &lt;em&gt;is&lt;/em&gt; possible to get there, and I can use this solution in the short run since I do not need the external flash for my current project, but I would very much prefer a solution that uses&amp;nbsp;Zephyr&amp;#39;s power management module.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Peder&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500127?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 08:06:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38dfd429-db93-4d4d-9bd0-fa9269ac6cb0</guid><dc:creator>boris bergman1</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1724832355756v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500125?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 08:03:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daddad65-5505-42fe-90e8-a2556e2c5004</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I know, but this was to help troubleshoot the problem. The PM suspend action will send the DPD command to the flash IC on the bus and then disable the QSPI peripheral afterward.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500123?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 07:57:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef6fb6b7-0172-4428-a94d-d6d5f439fdd3</guid><dc:creator>boris bergman1</dc:creator><description>[quote userid="4240" url="~/f/nordic-q-a/114224/external-flash-to-sleep/500104"] clarify what&amp;nbsp;you mean by &amp;#39;+150 mA&amp;#39;[/quote]
&lt;p&gt;Sorry my mistake, meant uA.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think I disabled QSPI, I just want to disable the flash device on the QSPI bus. I think indeed the flash device is using this much current, not the NRF52840, but I don&amp;#39;t understand why. Thanks for your help anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500104?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 06:08:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23c616e4-c729-46f2-b093-8c300d074c0f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming, but&amp;nbsp;could you clarify what&amp;nbsp;you mean by &amp;#39;+150 mA&amp;#39; when connecting? The nRF52840 can&amp;#39;t draw that much current by itself. It would also be&amp;nbsp;good if you could check&amp;nbsp;whether the QSPI peripheral&amp;nbsp;is&amp;nbsp;be enabled when you measure the&amp;nbsp; ~4 mA after it&amp;nbsp;the QSPI was supposed to be suspended. You can do so by reading the NRF_QSPI-&amp;gt;ENABLE register.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500075?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 20:39:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffbdf7c7-b28c-4225-97ee-7bdfe4f64a28</guid><dc:creator>boris bergman1</dc:creator><description>&lt;p&gt;No it does not, it is also reachable with ble (yes when connecting +150uA)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit: I meant uA, not mA.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500041?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 15:39:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b3155b9-77f1-44a7-8813-73a148d8ab7b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;So it is not going in a bootloop either?&amp;nbsp;A debug log should make it apparent if that&amp;#39;s the case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/500035?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 15:21:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eeb34152-929b-4286-a1ff-794bae5226b3</guid><dc:creator>boris bergman1</dc:creator><description>&lt;p&gt;No, it resides in low power state, executes a K_SLEEP()&lt;/p&gt;
&lt;p&gt;cpu_idle.s&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	 * For all the other ARM architectures that do not implement BASEPRI,
	 * PRIMASK is used as the interrupt locking mechanism, and it is not
	 * necessary to set PRIMASK here, as PRIMASK would have already been
	 * set by the caller as part of interrupt locking if necessary
	 * (i.e. if the caller sets _kernel.idle).
	 */
#endif /* CONFIG_ARMV7_M_ARMV8_M_MAINLINE */

	/* Enter low power state */
	_sleep_if_allowed wfi

	/*
	 * Clear PRIMASK and flush instruction buffer to immediately service
	 * the wake-up interrupt.
	 */
	cpsie	i
	isb

	bx	lr&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External flash to sleep</title><link>https://devzone.nordicsemi.com/thread/499951?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 10:41:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82480a1d-259f-4900-a44d-96280064abdb</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3.94mA could suggest that the CPU is prevented from entering sleep. Are you able to enable debug logging to see if there are any errors reported after&amp;nbsp;calling&amp;nbsp;pm_device_action_run()?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Vidar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>