<?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>Is there any spis event generated when the slave is selected?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24429/is-there-any-spis-event-generated-when-the-slave-is-selected</link><description>Currently I am using the spis driver to send data through the SPI peripheral. On the event handler I want to capture the time in which the chip is selected, which in the case of my application, is when the &amp;#39;slave select&amp;#39; signal goes low.
Is there any</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Aug 2017 09:03:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24429/is-there-any-spis-event-generated-when-the-slave-is-selected" /><item><title>RE: Is there any spis event generated when the slave is selected?</title><link>https://devzone.nordicsemi.com/thread/96211?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2017 09:03:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa8d2805-2eca-41ae-b66b-d4acd8257b3a</guid><dc:creator>J&amp;#248;rn</dc:creator><description>&lt;p&gt;Hello User1321&lt;/p&gt;
&lt;p&gt;I might have misinterpreted your question a bit, but I believe at least parts of my answer might still give you what you need.&lt;/p&gt;
&lt;p&gt;I have used a GPIOTE event on the CS pin, PPI and the Capture task of a timer.
I have attached a project, it is based on the SPIS example in SDK 14. I have added timer and PPI defines to sdk_config as well as the necessary .h and .c files. Please note that it is not optimized in any way.&lt;/p&gt;
&lt;p&gt;For my test I used a nRF52832 DK as slave and nRF52840 DK as master. The CS pin generates a GPIOTE event on toggle which triggers the capture task with the timer. The capture values are stored in seperate variables in the CS GPIOTE interrupt, in the gp_evt_handler.&lt;/p&gt;
&lt;p&gt;The slave transmits the difference between timer values back to the master, which displays it in the log in putty.&lt;/p&gt;
&lt;p&gt;The difference value you get is dependent on SPI bit-rate and timer clock rate. In the example the timer is set to 4MHz. The difference variable is a 16 bit value which is transmitted Least significant byte first. The actual time spent with CS low is found by dividing the difference value on the timer clock frequency.&lt;/p&gt;
&lt;p&gt;There is a delay from the time the CS pin falls, until the GPIOTE event handler executes which is roughly 24 us.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;DO NOTE: The timer is simply running free in this example, it is never stopped or cleared in a controlled fashion. If the timer overflows and restarts from zero between CS falling edge and CS rising edge you will get an erronous value.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Jørn Frøysa&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/spis-_2D00_-w-timer.zip"&gt;spis - w timer.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any spis event generated when the slave is selected?</title><link>https://devzone.nordicsemi.com/thread/96210?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2017 09:31:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1baf20a-f145-47c7-afd7-4afc36c63ddf</guid><dc:creator>User1321</dc:creator><description>&lt;p&gt;Yes, I tried putting the same spis_slave select pin on the GPIOTE interrupt configuration but on the initialization it gets restarted. When I change the interrupt pin to a different one, the GPIOTE interrupt works fine. I guess the same pin cannot be used to spi_slave select and also an GPIOTE interrupt.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any spis event generated when the slave is selected?</title><link>https://devzone.nordicsemi.com/thread/96209?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2017 09:21:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88ccfa54-26e0-4890-aa39-90be5222c29a</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;You mean that nRF52 is SPI slave, right? Have you tried GPIOTE interrupt on that PIN?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>