<?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>Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26288/problems-to-manage-spi-pins-to-communicate-with-the-slave</link><description>Hi to everyone! 
 I&amp;#39;m trying to use the nRF52832 board as master to use an external device (as slave) through SPI.
I take the example peripheral/SPI to start to learn how to work with this.
In the example I see the event but I don&amp;#39;t found when is triggered</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Nov 2017 08:23:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26288/problems-to-manage-spi-pins-to-communicate-with-the-slave" /><item><title>RE: Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/thread/103476?ContentTypeID=1</link><pubDate>Mon, 13 Nov 2017 08:23:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b817561f-71ac-47ee-9b38-1946c50decfd</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, normally SPI slave select pin is active low. Then you need to interchange the functions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/thread/103475?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 20:21:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be0305cd-4a81-428f-9bb9-e1e113aba0a2</guid><dc:creator>nemunoz</dc:creator><description>&lt;p&gt;Sorry but I find a mistake in the code. The clear and set functions are in the wrong positions. To fix it you must interchange them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/thread/103474?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 19:11:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae55151d-73eb-4e76-bcc4-a87791b15dd0</guid><dc:creator>nemunoz</dc:creator><description>&lt;p&gt;yeah! It works! Thank you so much!
I didn&amp;#39;t know I could do that!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry for answer you so late but I was also having problems to use the slave through SPI (an independent problem) so couldn&amp;#39;t try your solution before.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/thread/103473?ContentTypeID=1</link><pubDate>Fri, 27 Oct 2017 09:30:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3dccad0-5977-4815-b919-c621046b4006</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The &lt;code&gt;NRF_DRV_SPI_EVENT_DONE&lt;/code&gt; event is passed to the event handler when the transfer is doen. The Slave Select pin is optional in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.1.0/structnrf__drv__spi__config__t.html#a1f5f99c795ce50863cb244d771b756d0"&gt;SPI master driver config struct&lt;/a&gt;. If you set this pin to &lt;code&gt;NRF_SPI_PIN_NOT_CONNECTED&lt;/code&gt;, you can control the SS/CS pin yourself. You can then check if the MISO pin goes low before starting the SPI transfer. Something like the below code should work:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void spi_event_handler(nrf_drv_spi_evt_t const * p_event, void * p_context)
{
	nrf_gpio_pin_clear(SPI_SS_PIN);
}

void spi_transfer()
{
	nrf_gpio_pin_set(SPI_SS_PIN);
	while (nrf_gpio_pin_read(SPI_MISO_PIN))
	{
	}
	APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));
}

void main()
{
	nrf_gpio_cfg_output(SPI_SS_PIN);
	
	nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = NRF_SPI_PIN_NOT_CONNECTED;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
	
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));
	
	spi_transfer();
	
	while(1)
	{
		
	}
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/thread/103472?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 17:30:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4be1b2da-338a-4e6f-bf3d-646af5829ff7</guid><dc:creator>nemunoz</dc:creator><description>&lt;p&gt;The event handler is the third parameter of &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/group__nrf__drv__spi.html#ga2319de449c320ce104d8f3b40759c64c"&gt;nrf_drv_spi_init&lt;/a&gt; function (the event type is &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/group__nrf__drv__spi.html#gaecafc779dbf41db91ae9e43c863f55bc"&gt;nrf_drv_spi_evt_handler_t&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;The slave device is a radio frecuency chip CC1125 and the &lt;a href="http://www.ti.com/lit/ug/swru295e/swru295e.pdf"&gt;user&amp;#39;s guide&lt;/a&gt;, in the page 8 first paragraph, says:&lt;/p&gt;
&lt;p&gt;&amp;quot;When CSn is pulled low, the MCU must wait until CC112X SO pin goes low before starting to transfer the header byte. This indicates that the crystal is stable. Unless the chip was just reset or was in SLEEP or XOFF state, or the XOSC configuration has been altered, the SO pin will always go low immediately after pulling CSn low.&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems to manage SPI pins to communicate with the slave.</title><link>https://devzone.nordicsemi.com/thread/103471?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 12:41:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00102718-5bc7-4990-82a0-7008c028c66c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry but I don&amp;#39;t understand your questions. What event are you talking about? Where does the requirement that MISO needs to be driven low come from? If you are using the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/hardware_driver_spi_master.html?cp=4_0_1_2_12"&gt;SPI driver&lt;/a&gt;, this will handle the pins for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>