<?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 Master Example on nRF52 DK consistently fails</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9032/spi-master-example-on-nrf52-dk-consistently-fails</link><description>I&amp;#39;m trying the example in the SDK v0.9.1: examples\spi_master 
 When I load the project, build it, and debug it, all that happens is that it goes into a failed state where the error handler just does nothing: 
 void app_error_handler(uint32_t error_code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Sep 2015 07:16:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9032/spi-master-example-on-nrf52-dk-consistently-fails" /><item><title>RE: SPI Master Example on nRF52 DK consistently fails</title><link>https://devzone.nordicsemi.com/thread/33282?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 07:16:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:894862d5-41b8-45ae-92a2-98c16e014207</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Yes, you will need to wire MOSI to MISO. The example is transmitting bytes out on MOSI and at the same time it receives the same sequence of bytes on MISO. Then the example is comparing the transmitted bytes to the received bytes and if they are not the same your example will assert and stop running.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Master Example on nRF52 DK consistently fails</title><link>https://devzone.nordicsemi.com/thread/33281?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2015 17:14:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03e85fb1-50e1-4d84-923a-11669912dcef</guid><dc:creator>Papyrus</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Thanks for the response.  I have the other SPI instances disabled already.  In nrf_drv_config.h:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* SPI */
#define SPI0_ENABLED 1

#if (SPI0_ENABLED == 1)
#define SPI0_USE_EASY_DMA 0
//for DK w/ AS3911 Dev Kit
#define SPI0_CONFIG_SCK_PIN         4 
#define SPI0_CONFIG_MOSI_PIN        29
#define SPI0_CONFIG_MISO_PIN        28
#define SPI0_CONFIG_IRQ_PRIORITY    APP_IRQ_PRIORITY_LOW

#define SPI0_INSTANCE_INDEX 0
#endif

#define SPI1_ENABLED 0

#if (SPI1_ENABLED == 1)
#define SPI1_USE_EASY_DMA 0

#define SPI1_CONFIG_SCK_PIN         2
#define SPI1_CONFIG_MOSI_PIN        3
#define SPI1_CONFIG_MISO_PIN        4
#define SPI1_CONFIG_IRQ_PRIORITY    APP_IRQ_PRIORITY_LOW

#define SPI1_INSTANCE_INDEX (SPI0_ENABLED)
#endif

#define SPI2_ENABLED 0

#if (SPI2_ENABLED == 1)
#define SPI2_USE_EASY_DMA 0

#define SPI2_CONFIG_SCK_PIN         2
#define SPI2_CONFIG_MOSI_PIN        3
#define SPI2_CONFIG_MISO_PIN        4
#define SPI2_CONFIG_IRQ_PRIORITY    APP_IRQ_PRIORITY_LOW

#define SPI2_INSTANCE_INDEX (SPI0_ENABLED + SPI1_ENABLED)
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now what I can see from that other post is that I must wire the MISO-MOSI, which I don&amp;#39;t have, so that could also be it.  I am actually trying to communicate with a peripheral, so is that what is causing this problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Master Example on nRF52 DK consistently fails</title><link>https://devzone.nordicsemi.com/thread/33280?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2015 12:03:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f20556d3-4087-4dcc-9770-c326ede37074</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I just tested the example myself and I see something similar. I&amp;#39;m not sure if it is the exact same problem though.&lt;/p&gt;
&lt;p&gt;EDIT: First, remember that you will need to wire MOSI to MISO. The example is transmitting bytes out on MOSI and at the same time it receives the same sequence of bytes on MISO. Then the example is comparing the transmitted bytes to the received bytes and if they are not the same your example will assert and stop running.&lt;/p&gt;
&lt;p&gt;Second, what I discovered was that in nrf_drv_config.h all three SPI instances are enabled by default:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define SPI0_ENABLED 1
[...]
#define SPI1_ENABLED 1
[...]
#define SPI2_ENABLED 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This caused the switch_state() state machine in the example to transmit two bursts of data sequentially on each SPI instance. For this to work you will need to connect MOSI to MISO on all three SPI instances and I had only hooked up MOSI to MISO on SPI0. Otherwise these lines in spi_master_1_event_handler() will assert:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;result = check_buf_equal(m_tx_data_spi, m_rx_data_spi, TX_RX_MSG_LENGTH);
APP_ERROR_CHECK_BOOL(result) 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Defining SPI1_ENABLED and SPI2_ENABLED as 0, effectively disabling SPI1 &amp;amp; 2, solved the problem for me. After testing it I realized that it is actually documented &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk52.v0.9.1/spi_master_example_loopback.html?cp=4_0_0_4_5_17_0#spi_master_loopback_setup"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>