<?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>Send more than 256 bytes using nrf_drv_spi_transfer() in nRF52832 by manually control the SS pin</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97646/send-more-than-256-bytes-using-nrf_drv_spi_transfer-in-nrf52832-by-manually-control-the-ss-pin</link><description>Hi, 
 I need to send more than 256 bytes by SPI using the nrf_drv_spi_transfer() function.In this case is for programming or reading a 256 bytes page in a SPI Flash chip. In the same transmission (I mean the packet of bytes maintaining the CS low) I have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Mar 2023 14:22:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97646/send-more-than-256-bytes-using-nrf_drv_spi_transfer-in-nrf52832-by-manually-control-the-ss-pin" /><item><title>RE: Send more than 256 bytes using nrf_drv_spi_transfer() in nRF52832 by manually control the SS pin</title><link>https://devzone.nordicsemi.com/thread/415247?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2023 14:22:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64ce017f-b97b-4f6a-a530-951e4c01ee91</guid><dc:creator>jinvers</dc:creator><description>&lt;p&gt;Ok. Thank you.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Joel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send more than 256 bytes using nrf_drv_spi_transfer() in nRF52832 by manually control the SS pin</title><link>https://devzone.nordicsemi.com/thread/415212?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2023 12:54:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecead4a1-bcb9-437e-b6a0-8df12e1943c4</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]I have seen from the code of the nrfx_spim_xfer() function (called into the nrf_drv_spi_transfer function) I can only select the option NRFX_SPIM_PIN_NOT_USED of using ALL the SPI pins in this function or noone.[/quote]
&lt;p&gt;I&amp;#39;m not sure if I understand what you mean here. The pins are set when you initialize the driver (&lt;span&gt;nrfx_spim_init()), where you can set each individual pin to either the pin number or to&amp;nbsp;NRFX_SPIM_PIN_NOT_USED. The SS pin is controlled by software in the driver for all SPI instances in nRF52832, but if you set the pin to&amp;nbsp;NRFX_SPIM_PIN_NOT_USED, you can control the pin manually in your application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The code would be something like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define SPIM_SS_PIN 3
uint8_t spi_xfer_done = 0;

void spim_event_handler(nrfx_spim_evt_t const * p_event,
                       void *                  p_context)
{
	if(spi_xfer_done == 0)
	{
		// Start second transfer
		APP_ERROR_CHECK(nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0));
		spi_xfer_done++;
	}
	if(spi_xfer_done == 1)
	{
		// Second transfer done, deassert SS pin
		nrf_gpio_pin_set(SPIM_SS_PIN);
		spi_xfer_done = 2;
	}
}

vois spi_init(void)
{
    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
    spi_config.frequency      = NRF_SPIM_FREQ_1M;
    spi_config.ss_pin         = NRFX_SPIM_PIN_NOT_USED;
    spi_config.miso_pin       = NRFX_SPIM_MISO_PIN;
    spi_config.mosi_pin       = NRFX_SPIM_MOSI_PIN;
    spi_config.sck_pin        = NRFX_SPIM_SCK_PIN;
    APP_ERROR_CHECK(nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spim_event_handler, NULL));
	
	nrf_gpio_cfg_output(SPIM_SS_PIN);
	nrf_gpio_pin_set(SPIM_SS_PIN);
}

vois spi_transfer(void)
{
	spi_xfer_done = 0;
	// Assert SS pin before transfer
	nrf_gpio_pin_clear(SPIM_SS_PIN);
	
	APP_ERROR_CHECK(nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0));
}&lt;/pre&gt;&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>