<?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>nrf52832 (Ruuvi tag) sdk17 random high current usage / failure to sleep when using SPI to communicate with accelerometer.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67023/nrf52832-ruuvi-tag-sdk17-random-high-current-usage-failure-to-sleep-when-using-spi-to-communicate-with-accelerometer</link><description>I&amp;#39;ve read many similar issues that were raised regarding high SPI power consumption, looked at various examples, but can&amp;#39;t seem to find any issue that is close to what i&amp;#39;m observing. 
 I am developing a custom firmware for the RuuviTag that uses sdk17</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Jun 2021 08:34:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67023/nrf52832-ruuvi-tag-sdk17-random-high-current-usage-failure-to-sleep-when-using-spi-to-communicate-with-accelerometer" /><item><title>RE: nrf52832 (Ruuvi tag) sdk17 random high current usage / failure to sleep when using SPI to communicate with accelerometer.</title><link>https://devzone.nordicsemi.com/thread/314386?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2021 08:34:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:263aa4a0-5b2c-4c1c-8b48-ce1dec588713</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi, did you ever figure this out?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m doing almost the same thing but with the AIS2DW12 accelerometer.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/76139/high-sleep-current-with-spi-reading-accelerometer"&gt;devzone.nordicsemi.com/.../high-sleep-current-with-spi-reading-accelerometer&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 (Ruuvi tag) sdk17 random high current usage / failure to sleep when using SPI to communicate with accelerometer.</title><link>https://devzone.nordicsemi.com/thread/276284?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2020 15:39:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:850c8335-0b2c-4aca-9373-77c6da8669f6</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Is&amp;nbsp;&lt;em&gt;nrf_pwr_mgmt_run()&lt;/em&gt; used elsewhere, say in the main loop? Maybe try commenting this one out and simply waiting the 8 x n x 1uSecs for the SPI transfer to complete without trying to sleep and see how that effects the power. There are known errata with power. That assumes the LIS2DH12 is not read at very frequent intervals. The other option is to simply not use the nrf/nrfx code, instead using bare-metal drivers. I can post some if you don&amp;#39;t find any.&lt;/p&gt;
&lt;p&gt;As an aside, the LIS2DH12 works fine at 8MHz, though high drive CLK, /CS ans MOSI are recommended.&lt;/p&gt;
&lt;p&gt;Is the default mode 0, by the way? Worth checking but that would not probably make any difference.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  pSPIM-&amp;gt;CONFIG = 0;                        // CPOL 0 -- clock polarity active high, CPHA 1 -- sample on trailing clock edge, send Msb first
  pSPIM-&amp;gt;FREQUENCY = 0x80000000UL;          // LIS2DH12 works up to 10MHz on SPI
  pSPIM-&amp;gt;ORC =0;                            // Unused Tx bytes, set all low&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Lastly try running the SPIM as is but comment out the /CS low; that isolates the increased current to the nRF52 and away from something strange in the LIS2DH12.&lt;/p&gt;
&lt;p&gt;Errata issues, supposed to be in softdevice 7.2.0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void mSleep(void)
{
    // Errata 220: CPU: RAM is not ready when written - Disable IRQ while using WFE
    // Symptoms - Memory is not written in the first cycle after wake-up
    // Consequences - The address of the next instruction is not written to the stack. In stack frame, the link register is corrupted
    // Workaround
    // ==========
    // Enable SEVONPEND to disable interrupts so the internal events that generate the interrupt cause wakeuup in __WFE context and not in interrupt context
    // Before: ENABLE_WAKEUP_SOURCE -&amp;gt; __WFE -&amp;gt; WAKEUP_SOURCE_ISR -&amp;gt; CONTINUE_FROM_ISR  next line of __WFE
    // After:  ENABLE_WAKEUP_SOURCE -&amp;gt; SEVONPEND -&amp;gt; DISABLE_INTERRUPTS -&amp;gt; __WFE -&amp;gt; WAKEUP inside __WFE -&amp;gt; ENABLE_interrupts -&amp;gt; WAKEUP_SOURCE_ISR
    // Applications must not modify the SEVONPEND flag in the SCR register when running in priority levels higher than 6 (priority level numerical
    // values lower than 6) as this can lead to undefined behavior with SoftDevice enabled
    //
    // Errata 75: MWU: Increased current consumption
    // This has to be handled by turning off MWU but it is used in SoftDevice
    // see https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52832_EngB%2FERR%2FnRF52832%2FEngineeringB%2Flatest%2Fanomaly_832_75.html
    //
    // Errata 220: Enable SEVONPEND
    SCB-&amp;gt;SCR |= SCB_SCR_SEVONPEND_Msk;
    __disable_irq();
    // Errata 75: MWU Disable
    uint32_t MWU_AccessWatchMask = NRF_MWU-&amp;gt;REGIONEN &amp;amp; MWU_ACCESS_WATCH_MASK;
    // Handle MNU if any areas are enabled
    if (MWU_AccessWatchMask)
    {
        NRF_MWU-&amp;gt;REGIONENCLR = MWU_AccessWatchMask; // Disable write access watch in region[0] and PREGION[0]
        __WFE();
        __NOP(); __NOP(); __NOP(); __NOP();
        // Errata 75: MWU Enable
        NRF_MWU-&amp;gt;REGIONENSET = MWU_AccessWatchMask;
    }
    else
    {
        __WFE();
        __NOP(); __NOP(); __NOP(); __NOP();
    }
    __enable_irq();
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 (Ruuvi tag) sdk17 random high current usage / failure to sleep when using SPI to communicate with accelerometer.</title><link>https://devzone.nordicsemi.com/thread/276271?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2020 15:03:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2a0fe35-49c1-4447-9b4f-90828b5ca8f2</guid><dc:creator>nk1</dc:creator><description>&lt;p&gt;Still hopeful that someone else has also encountered this before!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>