<?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>Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61322/switching-between-blocking-and-non-blocking-spi</link><description>Hello, 
 I&amp;#39;m using the nrf52840 and SDKv16 to interface with an SD card. An SD card block is 512 bytes. I would like to do this: 
 1. Get the card ready for a write (use blocking SPI) 
 2. Write 512 bytes to SD card (use non blocking SPI) 
 3. Send the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 May 2020 16:24:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61322/switching-between-blocking-and-non-blocking-spi" /><item><title>RE: Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/thread/250030?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 16:24:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0246b2d0-e663-45ba-8181-10f10e7d6d42</guid><dc:creator>cwmoreiras</dc:creator><description>&lt;p&gt;In&amp;nbsp; case someone finds this thread who Is having trouble migrating from blocking to non blocking SPI (and needs EasyDMA to write large payloads), the link in the original post is excellent (including the discussion on how to make the DMA controller output the exact number of bytes). That, combined with Kenneth&amp;#39;s suggestion of using a flag when you need to block, is what did it for me.&lt;/p&gt;
&lt;p&gt;Beware of NRF_DRV_SPI_FLAG_TX_POSTINC vs NRF_DRV_SPI_FLAG_RX_POSTINC when setting flags for the DMA transfer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/thread/249921?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 11:14:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ebb1806-cdef-40ad-8d6a-c6502a18701a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;The use case of dynamically&amp;nbsp;switching&amp;nbsp;blocking and non-blocking seems a bit odd, since you get the exact same behavior as blocking by using non-blocking with a flag.&amp;nbsp;I expect it simply haven&amp;#39;t been considered, thereby not tested either. But I can report it so it is considered in the future.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/thread/249797?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 16:08:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19625df3-3f1d-48fa-80aa-7028f10c31ff</guid><dc:creator>cwmoreiras</dc:creator><description>&lt;p&gt;I&amp;#39;ll try it. Just so I understand, what would be the technical reason for this? I can dynamically change the frequency the SPI bus uses by uninitializing and reinitializing it (using nrf_drv_spi_init), so I&amp;#39;m surprised to see you say that I can&amp;#39;t change whether it&amp;#39;s blocking or non blocking by reinitializing it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/thread/249675?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 11:00:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bac9210c-c27b-4dda-b7bd-7d20b99d0758</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I think you will have to decide whether to use blocking or non-blocking. I don&amp;#39;t expect dynamically switching between the two&amp;nbsp;is something that have been considered. If you are using non-blocking, you can get the same behavior as blocking by&amp;nbsp;waiting for a flag after transfer (during this time you may put the CPU in sleep conserving power).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/thread/249569?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 18:56:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44701237-275d-473a-98c5-54e009b94bd9</guid><dc:creator>cwmoreiras</dc:creator><description>&lt;p&gt;I&amp;#39;m not using a file system (this is a constraint from the software that is used to retrieve data from the card after the data logging is done). I&amp;#39;d like to free up the CPU while the write is happening, so that it can continue to retrieve data from some sensors at a rate of 1 kHz. I&amp;#39;m using 8Mbps SPI, so one write will take about 512 us. This product also requires very low power and long battery life, so I want to sleep the CPU as much as I can.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching between blocking and non-blocking SPI</title><link>https://devzone.nordicsemi.com/thread/249568?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 18:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f70524b6-83d5-4da6-833c-7588d7014fca</guid><dc:creator>Turbo J</dc:creator><description>[quote userid="86885" url="~/f/nordic-q-a/61322/switching-between-blocking-and-non-blocking-spi"]Write 512 bytes to SD card (use non blocking SPI)[/quote]
&lt;p&gt;Why? The filesystem (I assume FatFS) requires the SPI transaction to be finished once the relevant (read/write) function returns. Non-blocking I/O has no benefit here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>