<?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>PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13523/ppi-to-spim-task-how-to</link><description>Hello, 
 I am having much fun with nrf52. I&amp;#39;d like to implement SPI read (few bytes) per GPIOTE event over PPI, the source is the GPIO event and the destination task is a SPI read of few specified bytes. The event is currently generated without Interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 May 2016 00:30:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13523/ppi-to-spim-task-how-to" /><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51619?ContentTypeID=1</link><pubDate>Mon, 09 May 2016 00:30:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50ab39f2-d364-44a5-b8ab-3ccf0c31bf26</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;The issue went away when I disabled all the SPIM interrupts.  Looking into this more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51620?ContentTypeID=1</link><pubDate>Sun, 08 May 2016 22:39:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de096bd4-805d-4576-aa17-d6717769d0cc</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;Ken, I have another strange issue today.  It amounts to SPIM PPI operation is breaking something.  I have a loop in main that toggles using&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_gpiote_out_toggle(testOutPin);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and have a uart print using&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_LOG_PRINTF(&amp;quot;In the loop \r\n&amp;quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As soon as the PPI channel for the SPIM is assigned, via&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_ppi_init();
nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel1);
nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel4);

nrf_drv_ppi_channel_assign(ppi_channel1,
  nrf_drv_gpiote_in_event_addr_get(AFE_DRDY_PIN),
  nrf_spim_task_address_get(NRF_SPIM0, NRF_SPIM_TASK_START));

nrf_drv_ppi_channel_assign(ppi_channel4,
  nrf_spim_event_address_get(NRF_SPIM0, NRF_SPIM_EVENT_ENDTX),
  nrf_spim_task_address_get(NRF_SPIM0, NRF_SPIM_TASK_STOP));

nrf_drv_ppi_channel_enable(ppi_channel1);
err_code = nrf_drv_ppi_channel_enable(ppi_channel4);

NRF_LOG_PRINTF(&amp;quot;err: %x \r\n&amp;quot;, err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The toggle and Uart Print stop working.  On a scope, the SPI is clocking and PPI works just fine.&lt;/p&gt;
&lt;p&gt;The SPI is setup as&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_SPIM0-&amp;gt;RXD.MAXCNT = 6; //AFE_STREAM_ARRAY_SIZE;
NRF_SPIM0-&amp;gt;RXD.PTR = (int32_t) &amp;amp;afeStreamArrayList;
NRF_SPIM0-&amp;gt;RXD.LIST = SPIM_RXD_LIST_LIST_ArrayList;

NRF_SPIM0-&amp;gt;TXD.MAXCNT = 3-1;
NRF_SPIM0-&amp;gt;TXD.PTR = (int32_t) bufTx;
NRF_SPIM0-&amp;gt;TXD.LIST = 0;

//spim_xfer()with
//nrf_drv_spi_xfer_desc_t xfer_desc;
//xfer_desc.rx_length = 6;

nrf_drv_spi_xfer(&amp;amp;afe_spi, &amp;amp;xfer_desc,
		//NRF_DRV_SPI_FLAG_RX_POSTINC
        //|NRF_DRV_SPI_FLAG_TX_POSTINC
		//|NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER
        NRF_DRV_SPI_FLAG_HOLD_XFER
        |NRF_DRV_SPI_FLAG_REPEATED_XFER
		);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What is going on?  Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51622?ContentTypeID=1</link><pubDate>Sun, 08 May 2016 14:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edf6f282-a33f-46ec-be91-da9d900b86d4</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;It is working now....  Hmm, I must have a double at my desk, that works when I am away.  Well actually I cleaned up some conflicting calls to the timer for debugging in the main loop.  It is working as how I wanted.  Thanks Ken!&lt;/p&gt;
&lt;p&gt;FI&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51621?ContentTypeID=1</link><pubDate>Sun, 08 May 2016 14:00:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a758de99-9708-4fa5-a83f-33448808b17f</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;Ken,  thanks for the response.  I was out a week.  Where it ended up was that, I set the timer in counter mode get counts from PIN event.  But was not able to have a compare event generated from the timer in the counter mode.  As you said, if it is possible, that would be great, I will get back to the code a little more and capture some code segment and maybe you can point out what I am doing wrong.  Thanks again.&lt;/p&gt;
&lt;p&gt;FI&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51618?ContentTypeID=1</link><pubDate>Tue, 03 May 2016 10:39:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:172fb39c-35f5-4b90-823a-eabcda55cfb5</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I don&amp;#39;t see any reason why there should not be generated a compare event in counter mode, I am though a bit unsure how it can be used in this case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51616?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2016 18:02:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2aa36ce-107b-4f9a-bbe9-70c2a081a6bf</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;Hi Ken,&lt;/p&gt;
&lt;p&gt;It there are way to generate event on a compare value when the timer is in counter mode?  I am thinking if I could count the SCK toggles and generate event based on a set number, it would give me more knobs to turn.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51617?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2016 07:38:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc52dc90-8784-4266-bf5c-902f3fa89112</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I still think you need CPU interaction here, but there are flags you can use when you are setting up the SPI transfer by nrf_drv_spi_xfer() such as NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER, NRF_DRV_SPI_FLAG_TX_POSTINC and NRF_DRV_SPI_FLAG_RX_POSTINC. So if you want to do multiple SPI transfers without CPU interrupt, then you can trigger the start task a number of times from a timer for instance. But you need to have some control on how many times you trigger the start task.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51615?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2016 03:05:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0650a6e-be9b-47ae-88db-5e69d5fc444d</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;Maybe an event from DataCount?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51614?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2016 01:16:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9544e02b-54a2-4204-a2e2-f27e8eb5d37d</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;Hello Ken,&lt;/p&gt;
&lt;p&gt;Per your instructions.  The PPI to SPI is working!  I&amp;#39;d like to shoot out another question before I call it the night.  So using SPIM the easyDMA is setup by defining MAXCNT, PTR and LIST type and ENABLE.  I have a buffer size of few bytes per transfer per event, what is the best way in the sense of no CPU intervention to append these data into a larger array? I noticed that if I put the larger buffer and pointer to it via the MAXCNT and PTR registers, each event would then trigger a SPI transfer of that large size, I only need a segment of few bytes.  I experimented by defining another transfer size when I call nrf_drv_spi_xfer(), but the MAXCNT supersedes. I also experiment with the flags NRF_DRV_SPI_FLAG_HOLD_XFER vs NRF_DRV_SPI_FLAG_REPEATED_XFER, but did not see a difference.  Your input is appreciated! Thanks again!&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51612?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2016 13:43:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:684c36e1-c04b-4e36-89b5-7a7e49635b21</guid><dc:creator>FI</dc:creator><description>&lt;p&gt;Great Ken, will check that out today.  Thanks!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI to SPIM Task, How to?</title><link>https://devzone.nordicsemi.com/thread/51613?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2016 12:29:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7827b8a8-cf65-43f9-b439-6e405122a0eb</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi, I suggest you combine two examples in the SDK:&lt;/p&gt;
&lt;p&gt;\examples\peripheral\saadc\&lt;br /&gt;
\examples\peripheral\spi\&lt;/p&gt;
&lt;p&gt;The first example show how you can setup a compare0 event from a timer to trigger an ADC conversion. In your case you need to include the SPI driver to trigger an SPI transfer instead.&lt;/p&gt;
&lt;p&gt;To setup the SPI transfer first call spim_xfer() with NRF_DRV_SPI_FLAG_HOLD_XFER flag. To get the actual task to trigger the SPI transfer use nrf_drv_spi_start_task_get(). Now you should only need replace nrf_drv_saadc_sample_task_get() with nrf_drv_spi_start_task_get(), and then the SPI transfer will be executed on every compare0 event. You can replace the compare0 event with any other event you want to trigger the transfer.&lt;/p&gt;
&lt;p&gt;Every time an SPI transfer is complete the application will be interrupted with spi_event_handler().&lt;/p&gt;
&lt;p&gt;There is however one problem here, the slave select pin is not toggled by itself, only the SCK, MISO and MOSI will be transferred. To include the slave select pin you might configure the compare0 event to trigger two tasks by setup two PPI channels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;one channel to toggle the slave select&lt;/li&gt;
&lt;li&gt;the second channel to start the spi transfer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The two tasks will then occur very close in time, this may or may not work depending on the SPI slave you are communicating with. Alternatively you will need to make this more intricate by having both a compare0 and compare1 event, to control the time between slave select go low until SPI transfer occur.&lt;/p&gt;
&lt;p&gt;There are many possibilities, but hope you have something to get you started.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>