<?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>Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111885/reducing-power-consumption-when-sd-card-is-unmounted</link><description>Our custom development board uses an nrf52840 chip together with attached sensors. The data from sensors are stored in sd card. For this purpose, the Zephyr fs library is used. In general, sensors&amp;#39; data are written into sd card successfully. The sd card</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Jul 2024 10:51:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111885/reducing-power-consumption-when-sd-card-is-unmounted" /><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/491561?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 10:51:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a69dbf2b-7297-4531-9e43-78ed06aba628</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Any logs would be useful here, in order to debug this further. If possible, also a small simple project that reproduce the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/489641?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2024 08:28:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8be66664-0052-4f5d-b809-a6a76d20d09c</guid><dc:creator>control</dc:creator><description>&lt;p&gt;Sorry, I did not express myself correctly. I just observed that some voltage appears on the MISO pin but I did not solve the problem.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/489562?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2024 13:59:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:484645f3-4157-4f45-bef7-9e1916022d02</guid><dc:creator>Sigurd</dc:creator><description>[quote user="control"]I measured voltages on SPI pins and observed when the SD card was unmounted, it was still sending&amp;nbsp;data to the NRF chip via the MISO pin which was the cause of the problem.[/quote]
&lt;p&gt;Were you able to fix this? Sounds like something went wrong with the&amp;nbsp;unmount.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/489416?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2024 07:41:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f017db12-e589-4d74-af19-c6890ac4c158</guid><dc:creator>control</dc:creator><description>&lt;p&gt;I do not have special logs. Both mentioned functions return 0. I measured voltages on SPI pins and observed when the SD card was unmounted, it was still sending&amp;nbsp;data to the NRF chip via the MISO pin which was the cause of the problem. If the SD card is removed and plugged in again, the power consumption is reduced to the expected value.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/489342?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2024 14:21:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00c31377-9523-4fd2-bae7-191ee018796c</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
[quote user="control"]&lt;div&gt;When&amp;nbsp;sd_card_close_file is called the power consumption does not decrease to the initial value but starts even increasing.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;[/quote]
&lt;p&gt;Do you have any logs from this?&lt;/p&gt;
&lt;p&gt;Did&amp;nbsp;pm_device_runtime_put(spi0_device) return 0 ?&lt;/p&gt;
&lt;p&gt;What does&amp;nbsp;&lt;span&gt;pm_device_runtime_is_enabled(spi0_device) return ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/488251?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2024 08:36:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68e15543-45b8-4517-ba3f-f0b2ef14f904</guid><dc:creator>control</dc:creator><description>&lt;p&gt;I try to implement your suggestion by using device runtime API. Here is my overlay file:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi0 {

&amp;#160; &amp;#160; compatible = &amp;quot;nordic,nrf-spi&amp;quot;; &amp;#160;
&amp;#160; &amp;#160; status = &amp;quot;okay&amp;quot;;
&amp;#160; &amp;#160;
&amp;#160; &amp;#160; pinctrl-0 = &amp;lt;&amp;amp;spi0_default&amp;gt;;
&amp;#160; &amp;#160; pinctrl-1 = &amp;lt;&amp;amp;spi0_sleep&amp;gt;;
&amp;#160; &amp;#160; pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;&amp;#160; &amp;#160;
&amp;#160; &amp;#160;&amp;#160;cs-gpios = &amp;lt;&amp;amp;gpio0 13 GPIO_ACTIVE_LOW&amp;gt;,
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;lt;&amp;amp;gpio1 6 GPIO_ACTIVE_LOW&amp;gt;,
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;lt;&amp;amp;gpio0 12 GPIO_ACTIVE_LOW&amp;gt;,
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;lt;&amp;amp;gpio0 15 GPIO_ACTIVE_LOW&amp;gt;;
&amp;#160; &amp;#160;
&amp;#160; &amp;#160;...
&amp;#160; &amp;#160; sdhc0: sdhc@3&amp;#160;{ &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; compatible = &amp;quot;zephyr,sdhc-spi-slot&amp;quot;;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; reg = &amp;lt;3&amp;gt;;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; status = &amp;quot;okay&amp;quot;;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; mmc {
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; compatible = &amp;quot;zephyr,sdmmc-disk&amp;quot;;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; status = &amp;quot;okay&amp;quot;;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; };
&amp;#160; &amp;#160; &amp;#160; &amp;#160; spi-max-frequency = &amp;lt;1000000&amp;gt;;
&amp;#160; &amp;#160; }; &amp;#160; &amp;#160;
};&lt;/pre&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;in sd_card.h I have the following define:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define SPI0_DEVICE_ID &amp;#160;DT_NODELABEL(spi0)&lt;/pre&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;and in sd_card.c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;struct device* spi0_device = DEVICE_DT_GET(SPI0_DEVICE_ID);
bool sd_card_ctor(void)
{

&amp;#160;return pm_device_runtime_enable(spi0_device) == 0;
}
void sd_card_init(void)
{ &amp;#160;
&amp;#160; &amp;#160; if(pm_device_runtime_get(spi0_device) == 0)
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;OK PM\n&amp;quot;);

&amp;#160; &amp;#160; int res = fs_mount(&amp;amp;mp); &amp;#160; &amp;#160;

&amp;#160; &amp;#160; if (res == FR_OK)
&amp;#160; &amp;#160; { &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;Disk mounted.\n&amp;quot;);
&amp;#160; &amp;#160; &amp;#160; &amp;#160; fs_file_t_init(&amp;amp;fs_file); &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; }
&amp;#160; &amp;#160; else
&amp;#160; &amp;#160; {
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;Error mounting disk.\n&amp;quot;); &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; }
}

void sd_card_close_file(void)
{
&amp;#160; &amp;#160; int res = fs_close(&amp;amp;fs_file);

&amp;#160; &amp;#160; if (res == FR_OK)
&amp;#160; &amp;#160; {
&amp;#160; &amp;#160; &amp;#160; &amp;#160; //printk(&amp;quot;FS close.\n&amp;quot;); &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; }
&amp;#160; &amp;#160; else
&amp;#160; &amp;#160; {
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;FS close error\n&amp;quot;); &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; }

&amp;#160; &amp;#160; res = fs_unmount(&amp;amp;mp); &amp;#160;

&amp;#160; &amp;#160; if (res == FR_OK)
&amp;#160; &amp;#160; {
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;Disk unmounted.\n&amp;quot;); &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; }
&amp;#160; &amp;#160; else
&amp;#160; &amp;#160; {
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;Error unmounting disk.\n&amp;quot;); &amp;#160; &amp;#160; &amp;#160; &amp;#160;
&amp;#160; &amp;#160; }
&amp;#160; &amp;#160;
&amp;#160; &amp;#160;
&amp;#160; &amp;#160; if(pm_device_runtime_put(spi0_device) == 0)
&amp;#160; &amp;#160; &amp;#160; &amp;#160; printk(&amp;quot;OK PM\n&amp;quot;);
}&lt;/pre&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;When&amp;nbsp;sd_card_close_file is called the power consumption does not decrease to the initial value but starts even increasing.&lt;/div&gt;
&lt;div&gt;I do not know what I am doing wrong. I would appreciate any help.&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reducing power consumption when sd card is unmounted</title><link>https://devzone.nordicsemi.com/thread/488070?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 09:30:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4218a2f3-2b9f-4ec5-b9b2-c43d9e702d00</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Maybe you could try to use the device power management API, and suspend the SPI&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/services/pm/device.html"&gt;https://docs.zephyrproject.org/latest/services/pm/device.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>