<?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>High sleep current with SPI reading accelerometer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76139/high-sleep-current-with-spi-reading-accelerometer</link><description>Using SDK15.3 and S140 
 
 following from my previous support request regarding TWI sleep current, I got the newer AIS2DW12 accelerometer and I have successfully connected it with SPI instead of TWI. 
 When power profiling I see occasional high sleep</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Jun 2021 11:56:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76139/high-sleep-current-with-spi-reading-accelerometer" /><item><title>RE: High sleep current with SPI reading accelerometer</title><link>https://devzone.nordicsemi.com/thread/314448?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2021 11:56:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adea049a-4608-4a19-83f2-9798fb9bb864</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;PPK2 Logic port to the rescue again!&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/ice_5F00_screenshot_5F00_20210609_2D00_135555.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Every time MOSI is left LOW, there&amp;#39;s high current in the accelerometer. The AIS2DW12 has an internal pull up which I cannot disable.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This code fixes it&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  nrf_drv_spi_uninit(&amp;amp;m_spi);
  nrf_gpio_pin_set(SPI_MOSI_PIN);
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High sleep current with SPI reading accelerometer</title><link>https://devzone.nordicsemi.com/thread/314422?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2021 10:17:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:521815b4-d179-4370-8cea-d0765b34020a</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;I&amp;#39;ve noticed it was a bit random whether it was high or low so I suspected it was related to the final bit being received from the accelerometer.&lt;/p&gt;
&lt;p&gt;If I add a completely unnecessary call to write a byte of zeros to an otherwise unused register on the accelerometer (Z_OFS_USR) then I get almost consistently low sleep current&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/ice_5F00_screenshot_5F00_20210609_2D00_121031.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I read the WHO_AM_I register then I get high sleep current 100% of the time&lt;/p&gt;
&lt;p&gt;Also, if I unplug the accelerometer from the PPK2 and give it power separately then I see consistently low sleep current.&lt;/p&gt;
&lt;p&gt;So at the moment, I think this is not nrf52 related. It&amp;#39;s the accelerometer somehow.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High sleep current with SPI reading accelerometer</title><link>https://devzone.nordicsemi.com/thread/314285?ContentTypeID=1</link><pubDate>Tue, 08 Jun 2021 18:56:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:005222ce-617e-4605-b51d-932e7cffc493</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;I&amp;#39;ve changed to the newer revision NRF52840 Dongle but it&amp;#39;s the same power profile.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My method of stopping SPIM1 is to call&amp;nbsp; nrf_drv_spi_uninit(&amp;amp;m_spi) after my last call to&amp;nbsp;nrf_drv_spi_transfer.&amp;nbsp; (after waiting for spi_xfer_done)&lt;/p&gt;
&lt;p&gt;Is this the correct method? I cannot see the implementation to check what it does.&lt;/p&gt;
&lt;p&gt;When I look in the NRF52840 product spec at 6.25.5 I see this&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1623177685684v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Should I instead use the ENABLE register?&lt;/p&gt;
&lt;p&gt;I assumed that when using the&amp;nbsp;&lt;span&gt;nrf_drv_spi_ calls then I shouldn&amp;#39;t need to touch the registers directly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I tried polling TASK_STOPPED with this code but it was always zero&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while (!NRF_SPIM1-&amp;gt;EVENTS_STOPPED)     printf (&amp;quot;X&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I also tried setting ENABLE = 0 after calling uninit but it didn&amp;#39;t make any difference.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  nrf_drv_spi_uninit(&amp;amp;m_spi);

  NRF_SPIM1-&amp;gt;ENABLE = 0;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>