<?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>SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69279/spim-transfer-crashing-on-nrf5340</link><description>Hi, 
 I&amp;#39;m developing a program using SPIM instance 1 on nRF5340 PDK, with nRF Connect SDK 1.4.0. 
 The problem I met is exactly the same as this post . If I want to use a handler, the SPI transfer will crash. 
 However, it seems I can not solve this problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Jan 2021 13:01:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69279/spim-transfer-crashing-on-nrf5340" /><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/289730?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 13:01:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6017f056-8607-41ae-8757-7311f9f44e1f</guid><dc:creator>Jason Lei</dc:creator><description>&lt;p&gt;&lt;span&gt;Thanks,&amp;nbsp;&lt;/span&gt;&lt;span&gt;J&amp;oslash;rgen. With your code above, now I can get into a SPI handler successfully.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/288955?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2021 14:19:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ad09d9c-2a36-4e20-841c-2b6bcbc633a3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for not getting back to you sooner on this issue.&lt;/p&gt;
&lt;p&gt;You can find a working nrfx SPIM example with handler in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/70105/how-to-use-spi-interface-in-a-zephyr-sample-example/288587#288587"&gt;this post&lt;/a&gt;.&amp;nbsp;I tested the example by building it for nrf5340dk_nrf5340_cpuapp target, but I had to modify one function in main.c to the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void manual_isr_setup()
{
#if defined(NRF9160_XXAA)
	IRQ_DIRECT_CONNECT(UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQn, 0,
			   nrfx_spim_1_irq_handler, 0);
	irq_enable(UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQn);

#elif defined(NRF5340_XXAA)
	IRQ_DIRECT_CONNECT(SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQn, 0,
			   nrfx_spim_1_irq_handler, 0);
	irq_enable(SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQn);
#else
	IRQ_DIRECT_CONNECT(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, 0,
			   nrfx_spim_1_irq_handler, 0);
	irq_enable(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn);
#endif
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can you check if you are able to use this example?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/285675?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 14:55:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ef42452-de75-4a0a-ab8f-c058d1df4b15</guid><dc:creator>Jason Lei</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi, J&amp;oslash;rgen.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m still stucking on this problem (though I can avoid this by not using any SPI handler). Do you have any other thoughts on this? Or could you provide with a SPIM sample project for nRF5340?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jason Lei&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/284225?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2020 05:57:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce020137-cd95-4c23-90b4-cd923a15b942</guid><dc:creator>Jason Lei</dc:creator><description>&lt;p&gt;Thanks,&amp;nbsp;&lt;span&gt;J&amp;oslash;rgen. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here&amp;#39;s my codes for initializing SPIM driver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;string.h&amp;gt;

#include &amp;lt;nrfx.h&amp;gt;
#include &amp;lt;nrfx_spim.h&amp;gt;
#include &amp;lt;nrfx_gpiote.h&amp;gt;
#include &amp;lt;nrfx_dppi.h&amp;gt;

#define SPI_INSTANCE			    1

#define SPI_CS_PIN 					4
#define SPI_SCK_PIN 				5
#define SPI_MOSI_PIN 				6
#define SPI_MISO_PIN 				7

nrfx_spim_t     spi	    =   NRFX_SPIM_INSTANCE(SPI_INSTANCE);


static void spi_event_handler(nrfx_spim_evt_t const * p_event, void * p_context)
{
	printk(&amp;quot;spi event!\n&amp;quot;); 
}


void spi_init(void)
{
	// err_code
	nrfx_err_t err;

	//cs pin
	nrfx_gpiote_out_config_t cs_gpio_config = NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
	err = nrfx_gpiote_out_init(SPI_CS_PIN, &amp;amp;cs_gpio_config);
	nrfx_gpiote_out_task_enable(SPI_CS_PIN);
	if (err != NRFX_SUCCESS)
		printk(&amp;quot;SPI_CS_init error: %08x \n&amp;quot;, err); 


	nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG(SPI_SCK_PIN, SPI_MOSI_PIN, SPI_MISO_PIN, NRFX_SPIM_PIN_NOT_USED);
	spi_config.mode = NRF_SPIM_MODE_1;
	spi_config.frequency = NRF_SPIM_FREQ_4M;

	err = nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL);

	if (err != NRFX_SUCCESS)
		printk(&amp;quot;SPIM_driver_init error: %08x \n&amp;quot;, err); 
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In the nrfx sample I mentioned above, there&amp;#39;s additional codes to init the GPIOTE&amp;nbsp;interrupt handler:&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;IRQ_CONNECT(DT_IRQN(DT_NODELABEL(gpiote)),
		    DT_IRQ(DT_NODELABEL(gpiote), priority),
		    nrfx_isr, nrfx_gpiote_irq_handler, 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I think this may be what I&amp;#39;m missing. Is there any documentation about how to init a SPI interrupt handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/284168?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2020 16:45:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:918ed968-b1d1-4c95-9f33-fe0ee7f005a1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/spim.html#register.TASKS_START"&gt;address of the SPI START task&lt;/a&gt; is static and can be found in the product specifications, you do not need to use any API to get this.&lt;/p&gt;
&lt;p&gt;Can you post the code you used for configuring/initializing the SPIM driver? Then I can try to reproduce this behavior.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/284145?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2020 15:34:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22aa2c63-ab72-4398-a2d5-d5cb03f9cee3</guid><dc:creator>Jason Lei</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;J&amp;oslash;rgen,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using NRFX APIs directly, because I want to use GPIO events to trigger SPI transmission directly (with DPPI). It seems I can not get the SPI START task address through Zephyr SPI API.&lt;/p&gt;
&lt;p&gt;The project I&amp;#39;m testing is modified from the nrfx sample (ncs/v1.4.0/zephyr/samples/boards/nrf). I enabled SPIM driver and SPIM1 instance using the &amp;quot;Configure nRF Connect SDK Project&amp;quot; interface in SEGGER Embedded Studio.&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_2A624F5C_2020_2D00_12_2D00_09-_0B4E4853_11.32.21.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM transfer crashing on nRF5340</title><link>https://devzone.nordicsemi.com/thread/284131?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2020 15:06:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d534bacf-ac81-42f0-ac84-a01fa4264422</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;How did you add SPI(M) to your application? Are you using the NRFX APIs directly, or do you use the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.0/zephyr/reference/peripherals/spi.html"&gt;Zephyr SPI API&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Can you post your prj.conf file, and any devicetree overlay files that you are using?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>