<?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>external interrupt -&amp;gt; PPI -&amp;gt; SPI burst reading (chip select )</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94277/external-interrupt---ppi---spi-burst-reading-chip-select</link><description>To the kind attention of Nordic support team, 
 
 Following PPI examples, I configured PPI so that an external interrupt (transition hi-&amp;gt;low on a gpio pin) is triggering a SPI reading. It works well. At least it works well when running in a specific program</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Nov 2022 10:14:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94277/external-interrupt---ppi---spi-burst-reading-chip-select" /><item><title>RE: external interrupt -&gt; PPI -&gt; SPI burst reading (chip select )</title><link>https://devzone.nordicsemi.com/thread/397820?ContentTypeID=1</link><pubDate>Mon, 28 Nov 2022 10:14:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97923f1c-e6c4-44a1-8bac-f117b1f7c603</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The easiest approach would be to use the nrfx driver and call&amp;nbsp;nrfx_spim_xfer() and pass&amp;nbsp;nrfx_spim_config_t as a parameter with the SS pin defined. Then the timing of the chip select pin will be implemented correctly by the driver. You can set a flag in the GPIOTE handler that is checked in the main loop and then execute the SPIM transfer. Something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int flag = 0;

void gpiote_event_handler(nrfx_spim_evt_t const * p_event,
                       void *                  p_context)
{
   flag = 1;

}

int main(void)
{
    ppi_init();
    nrfx_spim_init();
    while(1)
    {
        if(flag)
        {
            nrfx_spim_xfer();
            flag = 0;
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/13523/ppi-to-spim-task-how-to/51613"&gt;this &lt;/a&gt;comment by my colleague Kenneth is worth a read, especially his suggestion of having two compare events where one is for triggering the chip select pin and the other is for starting the transfer. It complicates the logic a bit, and maybe using the driver as I suggested over would be better for you. It all depends on how complex you want the code to be and your timing requirements.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt -&gt; PPI -&gt; SPI burst reading (chip select )</title><link>https://devzone.nordicsemi.com/thread/397756?ContentTypeID=1</link><pubDate>Sun, 27 Nov 2022 15:10:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2fa28d1-14b7-421b-af9b-3d5ad7b46941</guid><dc:creator>astella</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi guys, &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I found that chip select must be handled properly using PPI channels as well.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In particular external interrupt event is causing cs to be enabled AND spi reading task start ( that is why I used&amp;nbsp;&lt;/span&gt;&lt;span&gt;nrf_drv_ppi_channel_fork_assign, to have one event start two tasks)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then end spi event is causing cs to go high. In particular the chip select pin task is toggling. That is perfectly fine, given the right starting condition. Please Nordic, confirm at your convenience if it sounds good to you / you have any other suggestion about how to handle chip select.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>