<?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>SPI instance taking up a lot of power when enabled.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46300/spi-instance-taking-up-a-lot-of-power-when-enabled</link><description>SDK version: 15.3 
 Soft-device version: 6.1.1 
 
 Hi, 
 
 I&amp;#39;ve been working on a low power application where every 10&amp;#39;s of uA is important. My application requires SPI as Master on nRF52832 but as soon as I enable my SPI my current shoots up to mA range</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Apr 2019 20:36:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46300/spi-instance-taking-up-a-lot-of-power-when-enabled" /><item><title>RE: SPI instance taking up a lot of power when enabled.</title><link>https://devzone.nordicsemi.com/thread/183268?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 20:36:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db874ca7-832c-4b5b-bad0-5d93b2672f47</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;So when you get an interrupt the CPU wakes up and starts the SPI transfer. The CPU is on for a very sort time, but the run current can be as high as 8mA, depending on configuration.: &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/cpu.html?cp=3_1_0_6_1#topic"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/cpu.html?cp=3_1_0_6_1#topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The resolution on the PPK is probably not good enough to capture every CPU spike, but only the actual SPI run current which is 1.2-2mA depending on configuration. That&amp;#39;s probably why the peak current is varying.&lt;/p&gt;
&lt;p&gt;Can you try to use the trigger window instead? It has a higher resolution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI instance taking up a lot of power when enabled.</title><link>https://devzone.nordicsemi.com/thread/182485?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 07:44:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0be5794-38ce-48ae-a980-125efc5cee6c</guid><dc:creator>Jay_Shah</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I had figured it out on my own and had done the implementation with SW timer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There&amp;#39;s a weird thing that I&amp;#39;m noticing that, the current consumption is not same in every transaction.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I make a transaction in every 2 seconds, sometimes the current consumption is as low as 1.3mA and sometimes it&amp;#39;s as high as 7mA. RF and data logging is disabled only SPI is running on every 2 second interrupt.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2019_2D00_04_2D00_17-10_5F00_03_5F00_59_2D00_nRF-Connect-v2.6.2-_2D00_-Power-Profiler.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2019_2D00_04_2D00_17-10_5F00_11_5F00_18_2D00_nRF-Connect-v2.6.2-_2D00_-Power-Profiler.png" /&gt;&lt;/p&gt;
&lt;p&gt;What is the number shall I believe?&lt;/p&gt;
&lt;p&gt;Test Setup:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; I&amp;#39;m using nRF52DK with PPK.&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp; PPK is in DK mode and powered by DK.&lt;/p&gt;
&lt;p&gt;3.&amp;nbsp; DK is powered using USB (I understand that the document mentions that there will be uncertainty in measurements when powered with USB), but will the number be that bad? I&amp;#39;ve done my previous analysis with an Oscilloscope and that time it was powered with USB only so I want to keep the setup same by only swapping Oscilloscope with PPK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI instance taking up a lot of power when enabled.</title><link>https://devzone.nordicsemi.com/thread/182484?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 13:47:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c5c67a0-29a4-4450-a689-a1644605c111</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi, the SPI example is not power optimized. nrf_delay_ms() is just using a loop of NOP instructions. You should start the SPI transfer from an RTC interrupt or similar, and keep the CPU in a WFE loop.&lt;/p&gt;
&lt;p&gt;I modified the SPI example to include an app_timer which uses the RTC to give you an interrupt every 100ms. The power consumption is 2uA between the transfers. Also remember to disable logging in sdk_config.h.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;nrf_drv_spi.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;

#define SPI_INSTANCE  0 /**&amp;lt; SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */

#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[] = TEST_STRING;           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */

/**
 * @brief SPI user event handler.
 * @param event
 */
void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    NRF_LOG_INFO(&amp;quot;Transfer completed.&amp;quot;);
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}

static void spi_transfer_handler(void * p_context){
        memset(m_rx_buf, 0, m_length);
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS_PIN;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));

    NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART = 1;
    while(NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0){
    }
    NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
    APP_ERROR_CHECK(app_timer_init());
    APP_TIMER_DEF(spi_timer_id);
    APP_ERROR_CHECK(app_timer_create(&amp;amp;spi_timer_id, APP_TIMER_MODE_REPEATED, spi_transfer_handler));
    APP_ERROR_CHECK(app_timer_start(spi_timer_id, APP_TIMER_TICKS(100), NULL));

    NRF_LOG_INFO(&amp;quot;SPI example started.&amp;quot;);

    while (1)
    {
        NRF_LOG_FLUSH();
        __WFE();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>