<?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>nRF52832 SPI master read on external interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15244/nrf52832-spi-master-read-on-external-interrupt</link><description>Hello, 
 I would like to implement an interface with an external SPI ADC using the nRF52832.
The ADC has a RDY (ready) signal that goes low every time a new sample is ready to be read. 
 What I planned to do was to tie the RDY pin to an interrupt and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Jul 2016 13:50:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15244/nrf52832-spi-master-read-on-external-interrupt" /><item><title>RE: nRF52832 SPI master read on external interrupt</title><link>https://devzone.nordicsemi.com/thread/58210?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 13:50:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c23c4b8e-61e8-47a0-b87b-48b025f1d632</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;Thanks!
I believe this is enough for me to get started.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SPI master read on external interrupt</title><link>https://devzone.nordicsemi.com/thread/58209?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 12:06:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:599a2e8d-d08f-41cb-960a-4f71a0d0e7d8</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Real time events that require high priorities in the CPU is a hurdle, since the SoftDevice uses the highest priorities. However, your issue can be done almost completely without using CPU.&lt;/p&gt;
&lt;p&gt;You can set this up using &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/ppi.html?cp=2_2_0_21#concept_sxf_21l_1s"&gt;PPI&lt;/a&gt;, which is a hardware short between peripherals, to trigger on the input event from the ADC on a pin configured with &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/gpiote.html?cp=2_2_0_20#concept_knz_kww_lr"&gt;GPIOTE&lt;/a&gt;. Using PPI you can trigger a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html?cp=2_2_0_30#concept_j35_hv2_wr"&gt;SPI with EasyDMA&lt;/a&gt; task which will transfer directly to RAM. Then you can set a low priority interrupt flag and automatically deal with the data (if needed) when you have time.&lt;/p&gt;
&lt;p&gt;A very simple PPI example is provided below. The example gives a 8 MHz output on pin 18 using the capture compare event from the TIMER to trigger toggling of a GPIOTE output via PPI.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
    // Set up GPIO as output
    nrf_gpio_range_cfg_output(17, 18);
    nrf_gpio_pin_clear(17); // Light LED 1 to indicate that the code is running

    // Start high frequency clock
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
    {
        // Wait for clock to start
    }
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;

    // Configure GPIOTE to toggle pin 18 
    NRF_GPIOTE-&amp;gt;CONFIG[0] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos |
                            GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos |
                            18 &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                            GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;

    // Set up timer
    NRF_TIMER1-&amp;gt;PRESCALER = 0;
    NRF_TIMER1-&amp;gt;CC[0] = 2; // Adjust the output frequency by adjusting the CC.
    NRF_TIMER1-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos;
    NRF_TIMER1-&amp;gt;TASKS_START = 1;

    // Set up PPI to connect the timer compare event with the GPIOTE toggle task
    NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];
    NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];

    NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH0_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH0_Pos;

    while (true)
    {

    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make sure that you read the module descriptions thoroughly, also consult the SoftDevice specification, especially the part on which &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/sd_resource_reqs/hw_block_interrupt_vector.html?cp=2_3_0_0_6_0"&gt;hardware peripherals have restricted access&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>