<?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>SPI Slave Chip select  as an Interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3308/spi-slave-chip-select-as-an-interrupt</link><description>Hi,
I am planning to interface nRF51822 SPI( Slave ) port with another microcontroller. to achieve proper SPI synchronization , whenever nRF is ready to transmit data on SPI bus, it makes a GPIO output high ( Interrupt to microcontroller name it as INTERRUPT2CONTROLLER</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 02 Aug 2014 10:08:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3308/spi-slave-chip-select-as-an-interrupt" /><item><title>RE: SPI Slave Chip select  as an Interrupt</title><link>https://devzone.nordicsemi.com/thread/12060?ContentTypeID=1</link><pubDate>Sat, 02 Aug 2014 10:08:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6565b0d8-34c1-4fcb-a0f5-3455993680ff</guid><dc:creator>raju</dc:creator><description>&lt;p&gt;Hi Vince,
Thank you very much for your reply.
here there are 2 types of communications possible.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;when every nRF SPI Slave is ready with the data, sends an interrupt to Microcontroller ( By making INTERRUPT2CONTROLLER high) as a response Master initiates SPI transfer. ( can say SPI Master read operation )&lt;/li&gt;
&lt;li&gt;Master itself  want to send the data nRF ( Master SPI Write Operation)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;second scenario can occur at any time.( Slave should be ready always to receive the data)
in this case how can I manage. is it possible that SPI slave CS pin can be used as CS and Interrupt at the same time?
Thanking you very much.
Regards,
Rama Raju&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave Chip select  as an Interrupt</title><link>https://devzone.nordicsemi.com/thread/12059?ContentTypeID=1</link><pubDate>Thu, 31 Jul 2014 18:18:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb932310-eb89-4d77-8766-9b7fef6b3fc9</guid><dc:creator>Vince</dc:creator><description>&lt;p&gt;Hi Raju,&lt;/p&gt;
&lt;p&gt;IMHO the answer is yes, it is possible, but not at the same time. The easiest way is probably to use an external pull-up resistor on the INTERRUPT2CONTROLLER line and drive it both side as open-drain. If your master uC doesn&amp;#39;t provide this functionality, you can drive it low when you want it low and configure the pin as high-Z input when you want it high; the pull-up resistor will do the rest. Just take care never to drive that line high, as it could result in high current flow and even IO driver destruction.&lt;/p&gt;
&lt;p&gt;So, the following (untested) code should configure the pin as an active-high interrupt signal output, and drive it low (provided &lt;strong&gt;CS_PIN&lt;/strong&gt; is properly defined):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// disable SPI
NRF_SPIS1-&amp;gt;ENABLE &amp;amp;= ~(SPIS_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; SPIS_ENABLE_ENABLE_Pos);

// set CS_PIN as low-driven output
nrf_gpio_pin_clear(CS_PIN);
nrf_gpio_cfg_output(CS_PIN);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When your nFR device is ready to transmit, a call to &lt;strong&gt;spi_slave_init&lt;/strong&gt; should cleanly restart the SPI port and configure &lt;strong&gt;CS_PIN&lt;/strong&gt; back to input, making the line go high again.&lt;/p&gt;
&lt;p&gt;[edit (answering Raju's comment)]&lt;/p&gt;
&lt;p&gt;According to nRF51 reference manual chapters 13 (GPIO) and 26 (SPIS), enabling SPIS will override GPIO pins configuration, denying the use of CS as general purpose output. Anyway, you wanted the slave to hold the line low as long as there is no data to send, isn&amp;#39;t it? So here are some workarounds I can think of right now, as I assume using a dedicated IRQ line is not an option:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WA1:&lt;/strong&gt; accept compromise&lt;/p&gt;
&lt;p&gt;Is it really necessary to have an IRQ? Can&amp;#39;t you just buffer data on slave side and poll it with the master? And if it is about power consumption, can&amp;#39;t you delay master-to-slave transaction until the slave has data to send?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WA2:&lt;/strong&gt; the dirty way&lt;/p&gt;
&lt;p&gt;Only disable the SPIS when you need to draw an IRQ. You will need to make the interrupt active on falling edge. This will most probably result in data collision, but statistics and a good handshake protocol could save you...&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WA3:&lt;/strong&gt; if the nRF is the only slave device on the SPI bus&lt;/p&gt;
&lt;p&gt;Use SCK or MOSI to trigger the SPIS reactivation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WA4:&lt;/strong&gt; the hairy one&lt;/p&gt;
&lt;p&gt;Send an &amp;#39;illegal&amp;#39; SPI pattern you are sure the master will never send otherwise to trigger the SPIS reactivation, e.g. a pulse burst on MOSI while SCK stands still.&lt;/p&gt;
&lt;p&gt;[/edit]&lt;/p&gt;
&lt;p&gt;Please comment :)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vince&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>