<?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>Very simple SPI Code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4850/very-simple-spi-code</link><description>I am really struggling to get my ADXL345 SPI code working. Everything works fine on a LPC1768 and all outputs are fine on the nRF51822 Eval board, but there is no activity on the MISO pin.
Is there any reason why I could not implement a simple method</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Dec 2014 10:49:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4850/very-simple-spi-code" /><item><title>RE: Very simple SPI Code</title><link>https://devzone.nordicsemi.com/thread/17134?ContentTypeID=1</link><pubDate>Fri, 19 Dec 2014 10:49:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eaa258c1-8c72-4bdf-b6c9-67a719b254c6</guid><dc:creator>Annim</dc:creator><description>&lt;p&gt;Yes, please, add spi_master.h on your main.cpp and in libraries tree, add spi_master.c .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Very simple SPI Code</title><link>https://devzone.nordicsemi.com/thread/17133?ContentTypeID=1</link><pubDate>Fri, 19 Dec 2014 10:37:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f394e7e-21f9-422b-957e-454caae26f69</guid><dc:creator>Julian</dc:creator><description>&lt;p&gt;Thank you for your advice. Am I correct in assuming that you used spi_master.cpp from the Nordic SDK library?  I only ask this because I added it to my project and your code contains no #include statements and I am getting A LOT of compile errors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Very simple SPI Code</title><link>https://devzone.nordicsemi.com/thread/17132?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2014 06:43:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ecb6e7c-0222-4b61-b793-cbf97fa0ccbb</guid><dc:creator>Annim</dc:creator><description>&lt;p&gt;Please try out my sample code here posted. It is on adxl345 actually. It worked for me and its pretty much straight way. Hope this should work for you.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/22299/error-after-transmit-complete-event-in-spi-softdevice-enabled/?comment=23187#comment-23187"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Very simple SPI Code</title><link>https://devzone.nordicsemi.com/thread/17131?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2014 18:49:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:209e10b1-d0ad-4130-b708-bbc669296bdb</guid><dc:creator>Julian</dc:creator><description>&lt;p&gt;Yes. I modified the loopback example to fit the PCA10001 board and it worked fine, but I could not get it to work with the ADXL345. I also tried  examples from RedBearLab but to no avail. A major factor is probably my limited knowledge about event handling. that is why I wanted something REALLY SIMPLE that would also serve as learning curve for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Very simple SPI Code</title><link>https://devzone.nordicsemi.com/thread/17130?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2014 14:59:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0936a687-d86c-43f9-b427-27455ef4df50</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Julian&lt;/p&gt;
&lt;p&gt;Have you looked at the &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/doc/7.1.0/s110/html/a00033.html"&gt;SPI examples&lt;/a&gt; in the nRF51 SDK?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 17.12.2014&lt;/strong&gt;
I do not have something really simple SPI set up, but I think it should be possible to do it in these steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize the SPI master, similarly as is done in the spi_master_init function in the spi_master_example.&lt;/li&gt;
&lt;li&gt;Define the SPI IRQ handler and initialize it.&lt;/li&gt;
&lt;li&gt;Write a byte to TXD&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Anyway I think the easiest way to move forward is to use the SPI driver in perhaps a more simple way than the SPI loopback example does:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Define an event handler in your main function&lt;/li&gt;
&lt;li&gt;create RX and TX buffers and initialize them with data&lt;/li&gt;
&lt;li&gt;Initialize the SPI_0 master by calling spi_master_init with the name of the event handler you defined&lt;/li&gt;
&lt;li&gt;Call spi_send_recv function to send and receive data on the SPI&lt;/li&gt;
&lt;li&gt;Monitor your configured SPI pins with a logical analyzer or oscilloscope.&lt;/li&gt;
&lt;li&gt;First step is to see the clock signal on CLK pin and your TX data clocked out on MOSI pin.&lt;/li&gt;
&lt;li&gt;Next step would be to loop that data back into the MISO pin and check the RX buffer&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>