<?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>Accelerometer configuration issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68764/accelerometer-configuration-issue</link><description>Dear Concern, 
 
 
 
 we have tried to configure the accelerometer LSM6DSO module through SPI interface using NRF52xx DK board. External Module was not configured properly without minimum nrf_delay_ms(10). 
 Is any reason behind this delay, as it is not</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Nov 2020 19:00:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68764/accelerometer-configuration-issue" /><item><title>RE: Accelerometer configuration issue</title><link>https://devzone.nordicsemi.com/thread/282541?ContentTypeID=1</link><pubDate>Mon, 30 Nov 2020 19:00:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:160ebfac-f364-41c7-a6fb-6e69ffef961a</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Something to check, as this requirement for a delay often indicates a buffer inadvertently being placed on the stack and overwritten before the data has been completely used. In a function like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void mySpiStuff(void)
{
  uint8_t ctrl3_c_accelerometer[] = {1,2,3,4,5};
  if(nrf_drv_spi_transfer(&amp;amp;spi, ctrl3_c_accelerometer, sizeof(ctrl3_c_accelerometer), NULL, NULL) != NRFX_SUCCESS)
  {
    error = 12; return error;
  }
  //nrf_delay_ms(10); // Minimum delay required
  return ok;
}

void myOtherStuff(void)
{
  uint32_t stuff[8];
  .. blahBlah
}

void main(void)
{
  .. blahBlah
  mySpiStuff();
  myOtherStuff();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The problem is &lt;em&gt;myOtherStuff()&lt;/em&gt; runs before the SPI transfer is complete, which clobbers the data in&amp;nbsp;&lt;span&gt;&lt;em&gt;ctrl3_c_accelerometer&lt;/em&gt; before that data has completed the journey to the accelerometer. The fix is very simple, make&amp;nbsp;&lt;em&gt;ctrl3_c_accelerometer&lt;/em&gt;&amp;nbsp;static, which moves the location&amp;nbsp;off the stack and into safe memory:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t mySpiStuff(void)
{
  static uint8_t ctrl3_c_accelerometer[] = {1,2,3,4,5}; // &amp;lt;== use static!
  if(nrf_drv_spi_transfer(&amp;amp;spi, ctrl3_c_accelerometer, sizeof(ctrl3_c_accelerometer), NULL, NULL) != NRFX_SUCCESS)
  {
    error = 12; return error;
  }
  return ok;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If it&amp;#39;s any help, experienced programmers can make this mistake, and it makes a good interview question.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accelerometer configuration issue</title><link>https://devzone.nordicsemi.com/thread/282409?ContentTypeID=1</link><pubDate>Mon, 30 Nov 2020 10:35:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fb878c4-9d64-4102-ae3c-2895dc4b70a4</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As long as the data being sent on MOSI is correctly and is transmitted in expected time I think that the issue is probably related to the&amp;nbsp;&lt;strong&gt;&lt;span&gt;LSM6DSO&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;module. What exactly happens if you don&amp;#39;t include the delay? Do you see the expected data being transmitted from the nRF52? How does the LSM6DSO respond? I&amp;#39;m trying to get a better understanding of what the issue really is. Please include traces from a logic analyzer or similar where the difference is highlighted.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, what do you do in the code after you&amp;#39;ve started the transfer?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accelerometer configuration issue</title><link>https://devzone.nordicsemi.com/thread/282374?ContentTypeID=1</link><pubDate>Mon, 30 Nov 2020 07:02:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48a9b9ed-4006-4f46-9303-913888c89104</guid><dc:creator>SRINI</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;we have tried to configure the accelerometer LSM6DSO module through SPI interface using NRF52xx DK board. accelerometer LSM6DSO Module was not configured properly without minimum nrf_delay_ms(10).&lt;br /&gt; Code :&lt;br /&gt; if(nrf_drv_spi_transfer(&amp;amp;spi, ctrl3_c_accelerometer, sizeof(ctrl3_c_accelerometer), NULL, NULL) != NRFX_SUCCESS)&lt;br /&gt; {&lt;br /&gt; error = 12;&lt;br /&gt; return error;&lt;br /&gt; }&lt;br /&gt; nrf_delay_ms(10); // Minimum delay required &lt;br /&gt; Is any reason behind this delay, as it is not working without delay?&lt;br /&gt; could you please give us the suggestion how to avoid delay and is there alternate solution?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Regards,&lt;/div&gt;
&lt;div&gt;Srinivas Rao.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accelerometer configuration issue</title><link>https://devzone.nordicsemi.com/thread/281879?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2020 15:20:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4dfad782-96c6-4b1e-9696-2ee20950aab0</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Exactly where did you apply the delay? Could you show in the code?&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user=""]External Module was not configured properly without minimum nrf_delay_ms(10).[/quote]
&lt;p&gt;&amp;nbsp;What do you mean by this?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think this is a question that should be directed to Nordic&amp;nbsp;unless you only observe this with the Nordic MCU.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>