<?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>Control of SS pin of SPI with ppi.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63466/control-of-ss-pin-of-spi-with-ppi</link><description>Hi. 
 
 Development platform : nRF52833-DK, s113, SDK 16.0.0, IAR 8.31.1 
 
 I am making an example of periodically reading sensor data using SPI. 
 The SPI is triggered through PPI. 
 
 
 
 timer2 operates at 500us cycle. 
 Transmission of spi is started</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Aug 2020 00:28:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63466/control-of-ss-pin-of-spi-with-ppi" /><item><title>RE: Control of SS pin of SPI with ppi.</title><link>https://devzone.nordicsemi.com/thread/263087?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 00:28:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8db40128-eb14-4729-b11e-548cd71b099a</guid><dc:creator>jaeheung</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I solved it by using GPIOTE as below.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Thank you for your advice.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void power_sampling_event_init(void)
{
{
    nrfx_gpiote_out_config_t config = NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);

    uint32_t start_task_addr = nrf_drv_spi_start_task_get(&amp;amp;heater_volt_spi);
    uint32_t gpiote_task_addr;

    err_code = nrf_drv_gpiote_out_init(SPI_nCS_RVAC, &amp;amp;config);
    APP_ERROR_CHECK(err_code);

    gpiote_task_addr = nrfx_gpiote_clr_task_addr_get(SPI_nCS_RVAC);

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_voltage_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(m_ppi_voltage_channel, timer2_compare_event_addr, start_task_addr);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_ppi_channel_fork_assign(m_ppi_voltage_channel, gpiote_task_addr);
    APP_ERROR_CHECK(err_code);
}


{
  uint32_t start_event_addr = nrf_drv_spi_end_event_get(&amp;amp;heater_volt_spi);
  uint32_t gpiote_task_addr;
  
  gpiote_task_addr = nrfx_gpiote_set_task_addr_get(SPI_nCS_RVAC);

  err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_voltage_nCS_channel);
  APP_ERROR_CHECK(err_code);
  
  err_code = nrf_drv_ppi_channel_assign(m_ppi_voltage_nCS_channel, start_event_addr, gpiote_task_addr);
  APP_ERROR_CHECK(err_code);

}

    err_code = nrf_drv_ppi_channel_enable(m_ppi_voltage_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_enable(m_ppi_voltage_nCS_channel);
    APP_ERROR_CHECK(err_code);
    
    nrf_drv_gpiote_out_task_enable(SPI_nCS_RVAC);

}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Control of SS pin of SPI with ppi.</title><link>https://devzone.nordicsemi.com/thread/258808?ContentTypeID=1</link><pubDate>Tue, 07 Jul 2020 13:08:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a94eccf-7dee-46da-910f-3cad62583fab</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can use GPIOTE to toggle the SS pin, see the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/nrf_gpiote_example.html"&gt;GPIOTE example&lt;/a&gt; on how to set that up. If the slave does not require any time between SS and SCK, you can trigger the GPIOTE task on the same&amp;nbsp;&lt;span&gt;NRF_TIMER_EVENT_COMPARE0&amp;nbsp;event (using PPI fork), or alternatively a separate TIMER COMPARE event set to trigger a given time before the SPI transfer triggering event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Similarly, you can use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html#unique_1705305083"&gt;SPI END event&lt;/a&gt; to toggle the SS pin automatically again using GPIOTE after the transfer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>