<?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>Two SPIs conflict</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89668/two-spis-conflict</link><description>Dear all, 
 
 I have some problem with SPIs co-work. 
 I enabled two SPI instances in this project. 
 
 SPI Instance 1 function(non blocking mode - DMA enabled, 4Mbps): reading data from SPI sensor while DRDY pin triggered by sensor 
 SPI Instance 2 function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Jul 2022 09:50:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89668/two-spis-conflict" /><item><title>RE: Two SPIs conflict</title><link>https://devzone.nordicsemi.com/thread/375718?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2022 09:50:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc5dfa20-ad24-48d5-8062-00bbee0dad19</guid><dc:creator>Avadacadabara</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I managed to solve the problem by wirting in only one sector to flash at a time...But might not gonna work if sample rate is doubled.&lt;/p&gt;
&lt;p&gt;Your suggestion is helpful, I&amp;#39;ll modify the spi 2 structure for further development.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Ava&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPIs conflict</title><link>https://devzone.nordicsemi.com/thread/375713?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2022 09:33:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3631196-bd96-470e-9238-785f8b76b19c</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can do something like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;spi2_handler()
{
spi_xfer_done = true;
}

main()
{
...
spi_xfer_done = true;
...
while(1)
{
  if(spi_xfer_done == true)
  {
    // it&amp;#39;s possible to execute next spi2 transfer
  }
  // do other stuff
  
  sd_app_evt_wait(); // similar to WFE();
}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPIs conflict</title><link>https://devzone.nordicsemi.com/thread/375643?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2022 01:18:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a5a59f-0e09-415b-a57a-73326ea05a79</guid><dc:creator>Avadacadabara</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your advice.&lt;/p&gt;
&lt;p&gt;If I managed to switch spi 2 to non-blocking mode, I&amp;#39;ll stil need a &lt;pre class="ui-code" data-mode="c_cpp"&gt;while(!spi_xfer_done)
{
    __WFE();
}&lt;/pre&gt; after each transfer right? So I thought it might be no difference from blocking mode. Or do we have any method to avoid using while loop in main?&lt;/p&gt;
&lt;p&gt;Anyway I&amp;#39;ll work on turning spi 2 to non-blocking mode first.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Ava&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPIs conflict</title><link>https://devzone.nordicsemi.com/thread/375625?ContentTypeID=1</link><pubDate>Tue, 05 Jul 2022 18:00:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6020398-35b1-446d-8e6e-11174743da35</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Conseptually what you write should work. Though I don&amp;#39;t quite understand why you want to use blocking mode for SPI instance 2, you can still call it from main() even if you are using non-blocking mode. That should free up time in main handling ble or other events, instead of just waiting for an SPI instance 2 to complete a transfer. So I suggest to look into that for a start.&lt;/p&gt;
&lt;p&gt;In addition I am hoping you can have some GPIO&amp;#39;s here that you can use for debugging to try to understand what is actually occuring when data is lost. E.g.&lt;/p&gt;
&lt;p&gt;gpio1 - toggle when entering and exiting gpiote handler&lt;br /&gt;gpio2 - toggle before and after spi1 transfer&lt;br /&gt;gpio3 - toggle before and after spi2 transfer&lt;br /&gt;gpio4 - toggle each time you are writing data to the softdevice&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>