<?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>Whether the SPI using Easydma will occupy the CPU when transfer data？</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63667/whether-the-spi-using-easydma-will-occupy-the-cpu-when-transfer-data</link><description>Hello everyone 
 I have an question when I used the 52832. 
 First of all,I configed &amp;quot;nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL);&amp;quot; and the file (nrf_drv_spi.h) described the information as follow: 
 /** * @param handler Event handler</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Jul 2020 07:28:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63667/whether-the-spi-using-easydma-will-occupy-the-cpu-when-transfer-data" /><item><title>RE: Whether the SPI using Easydma will occupy the CPU when transfer data？</title><link>https://devzone.nordicsemi.com/thread/260276?ContentTypeID=1</link><pubDate>Thu, 16 Jul 2020 07:28:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed038034-491d-4feb-b49b-8355731a3cb5</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am not sure of when to update the m_rx_buf and m_tx_buf. That logic you can decide on yourself. It is not clear to me about when to use it. In your original code why you do a memcpy into m_rx_buf and not m_tx_buf is something i do not know.&lt;/p&gt;
&lt;p&gt;But based on your thoughts it sounds like the code in line number 15 (memcpy) should be before the nrf_drv_spi_transfer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whether the SPI using Easydma will occupy the CPU when transfer data？</title><link>https://devzone.nordicsemi.com/thread/260191?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 14:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dee0af89-ce81-4e1b-b101-f7eae0530783</guid><dc:creator>zhanglt3420</dc:creator><description>&lt;p&gt;After reading the code you gave,somewhere is in doubt.After using the nrf_drv_spi_transfer(),you call the&amp;nbsp; &amp;rsquo;memcpy(m_rx_buf,Quene_buf,5)&amp;lsquo; immediately.The value in the buffer &amp;lsquo;m_rx_bufer&amp;lsquo; maybe&amp;nbsp;invalid.Because the MISO pin maybe no signal at the same time.&lt;/p&gt;
&lt;p&gt;the code in the else{&amp;hellip;&amp;hellip;} is clearly.it can let the mcu enter the sleep mode and reduce the&amp;nbsp;Power consumption.Am I right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whether the SPI using Easydma will occupy the CPU when transfer data？</title><link>https://devzone.nordicsemi.com/thread/260056?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 08:18:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63ccebd4-5d36-480d-8f34-52077cad1739</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="zhanglt3420"]If i am right,I can move the statement 8 to spi_event_handle and remove the while(!spi_xfer_done).Therefore the MCU is&amp;nbsp;more efficient.[/quote]
&lt;p&gt;You need to WFE under a loop which is not relysolely on DRDY_READY. So I think what you have is good enough. Try this code&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;/**code**/

int main(void){

……

……

while{

        if（DRDY_READ &amp;amp;&amp;amp; spi_xfer_done）{
             DRDY_READ = false;
             spi_xfer_done = false;
             APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, 5, m_rx_buf, 5));
             memcpy(m_rx_buf,Quene_buf,5);

       }
       else{
            nrf_gpio_pin_clear(18);
           __SEV();
           __WFE();
           __WFE();
           nrf_gpio_pin_set(18);
       }

    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whether the SPI using Easydma will occupy the CPU when transfer data？</title><link>https://devzone.nordicsemi.com/thread/259806?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 07:44:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa23c2bb-164b-4756-a5ad-e09a92e860fe</guid><dc:creator>zhanglt3420</dc:creator><description>&lt;p&gt;Thanks a lot,Susheel.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the simple code I test is in below::&lt;/p&gt;
&lt;p&gt;/**code**/&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;int main(void){&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;hellip;&amp;hellip;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;hellip;&amp;hellip;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;while｛&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;while（DRDY_READY）{&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;0：APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, 5, m_rx_buf, 5));&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1：nrf_gpio_pin_clear(18);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;2：while (!spi_xfer_done)&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;3：{&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;4：NRF_LOG_INFO(&amp;quot;spi_xfer_done &amp;iexcl;&amp;shy;&amp;iexcl;&amp;shy;&amp;quot;); &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;5：__WFE(); &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;6：}&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;7：nrf_gpio_pin_set(18);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp;8：memcpy(m_rx_buf,Quene_buf,5);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;｝&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sometimes I need a few code below the Statement 7&amp;ldquo;&lt;span&gt;nrf_gpio_pin_set(18)&amp;ldquo; as like statement 8. I think my application is not suitable for using the while (!spi_xfer_done).Because external GPIO will Trigger an interrupt every 1ms(DRDY becomes true) and then I need to&lt;/span&gt;&lt;span&gt;&amp;nbsp;use the statement 0. If i am right,I can move the statement 8 to spi_event_handle and remove the while(!spi_xfer_done).Therefore the MCU is&amp;nbsp;more efficient.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whether the SPI using Easydma will occupy the CPU when transfer data？</title><link>https://devzone.nordicsemi.com/thread/259792?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 06:33:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1588f987-f3a6-4887-8d9e-e0348587ef44</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Zhang,&lt;/p&gt;
[quote user=""]&amp;nbsp; &amp;nbsp; &amp;nbsp;Now I want to use the SPI +Easydma to achieve the non_Block mode ,Start the SPI and EasyDMA,the code needs to free the CPU(52832),[/quote]
&lt;p&gt;The MCU is only needed to configure the SPI and the EasyDMA RX and TX PTR register, then trigger the transaction. The actual transfer done by EasyDMA after the task start is triggered done not involve the MCU.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]&amp;nbsp; &amp;nbsp;In my understanding,the time that started the SPI using EasyDma is just taking a few &amp;#39;us&amp;#39;.The EasyDma will do the remaining work. But actually it seems to have failed. The effection is the interrupt missed sometimes when start the second Fuction.[/quote]
&lt;p&gt;&amp;nbsp;We have tested the SPI and EasyDMA a lot and this is being used in many products already. So I am guessing that this most likely is not a hardware issue but something in the usage of the API.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]What I want to know&amp;nbsp;is that :&amp;nbsp;when I&amp;nbsp;use ‘while (!spi_xfer_done)&amp;nbsp;__WFE();’,will the CPU Free?&amp;nbsp; IF the SPI with EasyDma is non-block mode,the core can&amp;nbsp;achieve the two fuction .[/quote]
&lt;p&gt;&amp;nbsp;We normally recommend&amp;nbsp;&lt;span&gt;‘while (!spi_xfer_done) { __SEV(); __WFE();&amp;nbsp; __WFE();}’. Yes that should make the MCU go to sleep and will wakeit up when any other interrupt needs servicing. But since this is a while loop, it will go back to sleep until the spi_xfer_done is set to true. If you are using BLE and the softdevice, i would recommend you to use sd_app_evt_wait instead of the __WFE&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>