<?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>SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113153/spim-easydma-power-consumption</link><description>Hi, 
 We are working on power optimization for our project using the nRF5340 board. Our code implements an RTOS, BLE for data transfer, I2C and SPI for device communication, and UART for data logging. 
 When we disabled UART and all peripherals, including</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Sep 2024 17:00:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113153/spim-easydma-power-consumption" /><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/504043?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2024 17:00:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc6a6e84-f1b5-4eb7-ba21-1251fe36eede</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;your SPIM is active on pincontrol file&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;#39;&amp;#39;/* SPIM with easyDMA */&lt;br /&gt;&amp;amp;spi1 {&lt;br /&gt; compatible = &amp;quot;nordic,nrf-spim&amp;quot;;&lt;br /&gt; status = &amp;quot;okay&amp;quot;;&lt;br /&gt; pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;&lt;br /&gt; pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;&lt;br /&gt; pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;&lt;br /&gt;};&amp;#39;&amp;#39;&lt;/p&gt;
&lt;p&gt;You can use&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrfx_spim_uninit&lt;/code&gt;&lt;span&gt;&amp;nbsp;function to uninitialize the SPIM from your code. You also can try to disable the SPIM from device tree overlay file by disabling the peripheral.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;spi1&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt; status &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;quot;disabled&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&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;span&gt;}&lt;/span&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: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/500460?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2024 15:17:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75872861-6368-4458-8050-efb34eb73082</guid><dc:creator>Robotics Gun</dc:creator><description>&lt;p&gt;Hi, Kazi.&lt;/p&gt;
&lt;p&gt;I am also one of people who want to optimize power consumption for TWIM and SPIM.&lt;/p&gt;
&lt;p&gt;Since I am using NRFX driver (=not using zephyr since it&amp;#39;s not accesible/controllable for easyDMA), I have to do something for my own.&lt;/p&gt;
&lt;p&gt;For&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/maya_2e00_"&gt;Maya.&lt;/a&gt;&amp;nbsp;&amp;#39;s answer, I can&amp;#39;t understand how to disable the pins. Un-initializing SPIM, I understood but disabling pins, I don&amp;#39;t get it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;FYI, below is my code for TWIM and SPIM.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* TWIM with easyDMA */
&amp;amp;i2c0 {
	/* TWIM */
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	clock-frequency = &amp;lt;I2C_BITRATE_FAST&amp;gt;;
	pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c0_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

/* SPIM with easyDMA */
&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* SPI(M) gpio */
#define MOSI_PIN_SPIM 13 // SPIM pin number for MOSI.
#define MISO_PIN_SPIM 12 // SPIM pin number for MISO.
#define SCK_PIN_SPIM 14  // SPIM pin number for SCK.
#define SS_PIN_SPIM 15   // SPIM pin number for CS.

/* SPI SCLK (=clock) speed */
#define SPIM_SCK_SPEED_MHZ 8

/**
 * @brief Symbol specifying SPIM instance to be used.
 * note: SPI1 for ACCEL/GYRO sensor communication (I2C0 shares the device register with SPI0 and its already used for Magnetometer)
 */
// #define SPIM_INST_IDX 0
#define SPIM_INST_IDX 1

/* Declare the SPIM instance variable using the macro directly */
static const nrfx_spim_t spim_instance = NRFX_SPIM_INSTANCE(SPIM_INST_IDX);

nrfx_err_t init_spim(nrfx_spim_evt_handler_t handler)
{
    nrfx_err_t status;

    nrfx_spim_config_t spim_config = NRFX_SPIM_DEFAULT_CONFIG(SCK_PIN_SPIM, MOSI_PIN_SPIM, MISO_PIN_SPIM, SS_PIN_SPIM);
    spim_config.mode = NRF_SPIM_MODE_3;
    spim_config.frequency = NRFX_MHZ_TO_HZ(SPIM_SCK_SPEED_MHZ);

    status = nrfx_spim_init(&amp;amp;spim_instance, &amp;amp;spim_config, handler, NULL);
    if (status != NRFX_SUCCESS)
    {
        ACCEL_GYRO_SPIM_DEBUG(&amp;quot;Failed to initialize SPIM instance: %d&amp;quot;, status);
        return status;
    }

    IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIM_INST_GET(SPIM_INST_IDX)), IRQ_PRIO_LOWEST,
                NRFX_SPIM_INST_HANDLER_GET(SPIM_INST_IDX), 0, 0);
    irq_enable(NRFX_IRQ_NUMBER_GET(NRF_SPIM_INST_GET(SPIM_INST_IDX)));

    ACCEL_GYRO_SPIM_DEBUG(&amp;quot;SPIM instance initialized successfully&amp;quot;);
    return NRFX_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define SCL_PIN_TWIM 17
#define SDA_PIN_TWIM 18

/** @brief Symbol specifying TWIM instance to be used. */
#define TWIM_INST_IDX 0

/** @brief Structure containing TWIM driver instance. */
static nrfx_twim_t twim_inst = NRFX_TWIM_INSTANCE(TWIM_INST_IDX);


nrfx_err_t twim_init(nrfx_twim_evt_handler_t handler)
{
    nrfx_err_t status;

    IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_TWIM_INST_GET(TWIM_INST_IDX)), IRQ_PRIO_LOWEST,
                NRFX_TWIM_INST_HANDLER_GET(TWIM_INST_IDX), 0, 0);

    nrfx_twim_config_t twim_config = NRFX_TWIM_DEFAULT_CONFIG(SCL_PIN_TWIM, SDA_PIN_TWIM);
    twim_config.frequency = NRF_TWIM_FREQ_400K; // i2c speed: 400kHz
    // twim_config.frequency = NRF_TWIM_FREQ_390K; // i2c speed: 390kHz
    // twim_config.frequency = NRF_TWIM_FREQ_100K; // i2c speed: 100kHz

    void *p_context = &amp;quot;--&amp;gt; Master event: done - transfer completed&amp;quot;;
    status = nrfx_twim_init(&amp;amp;twim_inst, &amp;amp;twim_config, handler, p_context);
    if (status != NRFX_SUCCESS)
    {
        MAGNETO_TWIM_DEBUG(&amp;quot;twim_init() -&amp;gt; nrfx_twim_xfer() failed: %d\n&amp;quot;, status);
        return status;
    }

    nrfx_twim_enable(&amp;amp;twim_inst);

    return status;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What community needs is simple.&lt;/p&gt;
&lt;p&gt;Just sample with the APIs for power saving mode for TWIM and SPIM.&lt;/p&gt;
&lt;p&gt;Even if&amp;nbsp;I invested times to check the forum and technical document, I can&amp;#39;t find proper ones.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/497515?ContentTypeID=1</link><pubDate>Thu, 08 Aug 2024 16:43:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6f7e3d2-df2e-4b8d-8089-0c6bcfce7fb9</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;hello,&lt;/p&gt;
&lt;p&gt;Good to here that.&lt;/p&gt;
&lt;p&gt;&amp;#39;&amp;#39;&lt;span&gt;We&amp;nbsp;&lt;/span&gt;&lt;span&gt;were able to&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;reduced our base current to below 1mA when SPI is enabled in overlay.&amp;#39;&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is not it already enabled in overlay file?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#39;&amp;#39;&lt;span&gt;We achieved this by uninitializing the SPIM after each SPI transfer function call and also uninitializing the SPIM SCK, MISO, and MOSI pins once the transmission is complete&amp;#39;&amp;#39; _ this is done in code. If you want can share to the community.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/496971?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2024 12:30:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8080c438-aa72-483a-a740-0b554922aed5</guid><dc:creator>Maya.</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We &lt;span&gt;were able to&amp;nbsp;&lt;/span&gt; reduced our base current to below 1mA when SPI is enabled in overlay. We achieved this by uninitializing the SPIM after each SPI transfer function call and also uninitializing the SPIM SCK, MISO, and MOSI pins once the transmission is complete.&lt;br /&gt;We didn&amp;#39;t use the &amp;quot;pm_device_action_run&amp;quot; function call because it did not result in any decrease in current when we tested it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/496749?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2024 04:17:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f68ef69-9181-4b82-a2ce-cc73f7e9a076</guid><dc:creator>Maya.</dc:creator><description>&lt;p&gt;yes , we are testing in our custom board&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/496690?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 16:32:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1ab1f28-9e5a-4fb8-ad4a-73e2e9a8fddd</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have tried your both projects and got average current 620uA for both applications.&lt;/p&gt;
&lt;p&gt;These two files are same. I can not see any change. Did you upload the right file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/496580?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 09:52:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d3aef52-0838-4908-9fc4-6dd745d12944</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;One more thing. Is this your custom board?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/496578?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 09:50:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da34a590-c1cc-4e20-b7cf-45685f333b22</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have been working on your case. I will get back to you today.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/495134?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2024 06:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16dae060-a89c-41d9-b3f8-5e131d4d9150</guid><dc:creator>Maya.</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We are currently using SDK version v2.4.2 in our code. When we looked online, we couldn&amp;#39;t find any power optimization references in the SPIM documents provided by Nordic for version v2.4.2. However, we found power optimization references in the latest SDK versions.&lt;/p&gt;
&lt;p&gt;It looks like we will need to optimize the power consumption of SPIM manually in our code.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If doing it manually, what should we do to achieve lower current consumption?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We are unable to move forward with the power optimization due to this SPIM issue we&amp;#39;re facing. Your input will be highly valuable.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/495013?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2024 12:11:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adba6d8f-5b84-434b-ba31-e6db1359c478</guid><dc:creator>Maya.</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We enabled SPIM (EasyDMA) for NAND communication and disabled all other peripherals to measure the current consumed by the SPIM peripheral alone. Here are our observations:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2024_2D00_07_2D00_22-172625.png" /&gt;&lt;/p&gt;
&lt;p&gt;This is the code we used:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/spim_5F00_test_5F00_sample.zip"&gt;devzone.nordicsemi.com/.../spim_5F00_test_5F00_sample.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As we observed that calling the PM function did not significantly reduce the current consumption. To clear our doubts, we tried the same with SPI code and made the following observations:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2024_2D00_07_2D00_22-173308.png" /&gt;&lt;/p&gt;
&lt;p&gt;This is the sample code:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/spi_5F00_test_5F00_sample.zip"&gt;devzone.nordicsemi.com/.../spi_5F00_test_5F00_sample.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Using SPI, it seems the device enters suspend mode when calling the function.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We would like to know how we can achieve the same low current consumption when using SPIM instead of SPI.&lt;/li&gt;
&lt;li&gt;Why is the device not going into suspend mode when using SPIM APIs?&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/trampas"&gt;trampas&lt;/a&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/kazi-afroza-sultana"&gt;Kazi Afroza Sultana&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/494873?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 17:04:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3845363-c1a8-440d-b540-49e0625488e3</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You can try to abort the transaction and then apply the PM action to put the device in low power.&lt;/p&gt;
&lt;p&gt;For example, *p_instance is a pointer to the SPIM peripheral instance&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfx_spim_t const *p_instance;

//Abort the ongoing transfer

nrfx_spim_abort(p_instance)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then can try this as you have already in your code:&lt;/p&gt;
&lt;p&gt;ret = pm_device_action_run(self-&amp;gt;spi_dev, PM_DEVICE_ACTION_SUSPEND);&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this CONFIG_PM_DEVICE=y enabled in config file?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kazi&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM (EasyDMA) power consumption</title><link>https://devzone.nordicsemi.com/thread/494669?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2024 22:02:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4da596a3-712c-4141-9b8e-4d85c93be141</guid><dc:creator>trampas</dc:creator><description>&lt;p&gt;Have you checked the state of the SPI pins during sleep, specifically they need to be pulled high.&amp;nbsp; Especially the chip select pin, as it usually has an external pull up on the PCB.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>