<?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>SPI manager queue limitations</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21649/spi-manager-queue-limitations</link><description>Hi all, 
 Having a bit of an issue with the SPI manager scheduler. When sending small packets (&amp;lt;4 bytes), I seem to be able to queue as many requests as I want. 
 However, sending a larger packet - even without any other requests in the queue (in this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Apr 2017 18:22:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21649/spi-manager-queue-limitations" /><item><title>RE: SPI manager queue limitations</title><link>https://devzone.nordicsemi.com/thread/84971?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2017 18:22:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43888598-a4f7-40be-8999-af0dabd4e816</guid><dc:creator>Jakub Rzeszutko</dc:creator><description>&lt;p&gt;Hi Daniel,&lt;/p&gt;
&lt;p&gt;Your first solution will not work as you expect. You are passing to function nrf_spi_mngr_schedule address of variable: command_trans. Unfortunately this variable is on stack and will be not valid as soon as you leave send_data_async function. Please try solution proposed by Petter and add static keyword to variables: command_trans and packet .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI manager queue limitations</title><link>https://devzone.nordicsemi.com/thread/84969?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2017 13:56:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:caa998ae-a039-4725-8eb6-5979857b6285</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;What if you make them static? Like &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/lib_nrf_spi_mngr.html?cp=4_0_0_3_38"&gt;here&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI manager queue limitations</title><link>https://devzone.nordicsemi.com/thread/84970?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2017 12:20:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d31b78c1-a182-48f7-a1a8-a35a36312ee0</guid><dc:creator>Daniel Sullivan</dc:creator><description>&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt; HORRIBLE TEMPORARY SOLUTION &lt;strong&gt;WARNING&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Just to get this working in the meantime, since 8 byte transfers seem to work with no trouble, I&amp;#39;ve written a small routine to break larger packets into 8 byte transfers which are then given to the transaction as an array for queueing. It doesn&amp;#39;t look as nice on the logic analyser, but as far as I understand SPI, breaking strings is allowed in this manner as long as the bits are still clocked out the same.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void send_data_async(uint8_t * data, size_t len, uint8_t * handler) {
// Number of packets
uint8_t no_pkts = (len + 7) / 8;

// Packet definition
nrf_spi_mngr_transfer_t packet[no_pkts];

uint8_t progress = 0;
for (uint8_t i = 0; i &amp;lt; no_pkts; ++i) {
	uint8_t send_len;
	if ((len - progress) &amp;lt; 8 ) {
		send_len = len - progress;
	} else {
		send_len = 8;
	}
	
packet[i].p_tx_data = (uint8_t const *) data + progress;
packet[i].tx_length = (uint8_t)        send_len;
	packet[i].p_rx_data = (uint8_t *)      NULL;
packet[i].rx_length = (uint8_t)        0;

	progress = progress + 8;
}

// Transaction	
nrf_spi_mngr_transaction_t data_trans = {
					.begin_callback      = start_data_callback,
        .end_callback        = finish_data_callback,
        .p_user_data         = NULL,
        .p_transfers         = packet,
        .number_of_transfers = no_pkts,
        .p_required_spi_cfg  = NULL
};

// Queue
APP_ERROR_CHECK(nrf_spi_mngr_schedule(&amp;amp;m_nrf_spi_mngr, &amp;amp;data_trans));

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;DISCLAIMER: I am not originally a C programmer. They are probably MUCH better ways to do this. If anyone wants to offer any suggestions, or if anyone from Nordic has a clue why this is happening in the first place, it would be very much appreciated!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>