<?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>use spi dma/easyDMA in a fifo manure, or cyclic queue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96706/use-spi-dma-easydma-in-a-fifo-manure-or-cyclic-queue</link><description>hello Nordic 
 i am working with nrf52832 and nrf52840, with ncs 1.9.2 with zephyr 
 i am sampling a sensor at high speed, i set spi_xfer call to read 8 bytes from the sensor every time there is a sample, this happens many times via ppi and a timer. </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Feb 2023 23:16:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96706/use-spi-dma-easydma-in-a-fifo-manure-or-cyclic-queue" /><item><title>RE: use spi dma/easyDMA in a fifo manure, or cyclic queue</title><link>https://devzone.nordicsemi.com/thread/410197?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 23:16:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a55987f7-b5e6-4083-ae99-81c70d6dc2e6</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I suggest you use the&amp;nbsp;&lt;a title="EasyDMA list" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html?cp=5_2_0_30_1_0#topic"&gt;EasyDMA list&lt;/a&gt;&amp;nbsp;feature of the SPIM. This will require you to use the nrfx_spim driver and HAL directly instead of relying on zephyr&amp;#39;s SPI device driver API, as you will want to handle CS/CONVST and&amp;nbsp;SPIM&amp;#39;s&amp;nbsp;&lt;span&gt;TASKS_START&lt;/span&gt; task with a TIMER.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The DMA list feature (&lt;a title="RXD.LIST" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/spim.html?cp=5_0_0_5_24_5_22#register.RXD.LIST"&gt;RXD.LIST&lt;/a&gt;) increments the &lt;a title="RXD.PTR" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/spim.html?cp=5_0_0_5_24_5_19#register.RXD.PTR"&gt;RXD.PTR&lt;/a&gt;&amp;nbsp;after an&amp;nbsp;&lt;span&gt;EVENTS_END. The SPIM is then ready for the next transfer. You can disable the SPIM interrupts entirely, and let the ArrayList buffer fill up. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is a catch however and that is that the SPIM does not know the size of the DMA list, nor have any mechanism to stop the SPIM from overflowing the DMA list if&amp;nbsp;TASKS_START is triggered after the DMA list buffer is full.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You will therefore need to count the number of times&amp;nbsp;EVENTS_STARTED has been triggered and manually update&amp;nbsp;&lt;a title="RXD.PTR" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/spim.html?cp=5_0_0_5_24_5_19#register.RXD.PTR"&gt;RXD.PTR&lt;/a&gt;&amp;nbsp;to the next DMA list buffer.&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This can be done by triggering a TIMER&amp;#39;s TASKS_COUNT (in counter mode),&amp;nbsp;on&amp;nbsp;EVENTS_STARTED. And enabling a COMPARE event after &amp;#39;X&amp;#39;&amp;nbsp;EVENTS_STARTED, where &amp;#39;X&amp;#39; is the size, in bytes, of your DMA list buffer divided by&amp;nbsp;&lt;a title="  RXD.MAXCNT  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html?cp=5_2_0_30_5_9#register.RXD.MAXCNT"&gt;RXD.MAXCNT&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The TIMER&amp;#39;s COMPARE interrupt will then signal that your DMA list buffer is about to be full and that you need update&amp;nbsp;&lt;a title="RXD.PTR" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/spim.html?cp=5_0_0_5_24_5_19#register.RXD.PTR"&gt;RXD.PTR&lt;/a&gt;&amp;nbsp;with the address to the next DMA list buffer.&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;With this implementation the ADC sampling will have minimal impact&amp;nbsp;with respect to scheduling overheads.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>