<?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 driver implementation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66784/spi-driver-implementation</link><description>Hi, 
 I&amp;#39;m using an nRF52840 and I need to implement a driver in c for an external chip. The c driver is written, and I only need to add specific functions regarding the SPI like a function for transmitting bytes and another function to receiving bytes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Oct 2020 09:16:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66784/spi-driver-implementation" /><item><title>RE: SPI driver implementation</title><link>https://devzone.nordicsemi.com/thread/275533?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 09:16:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dede55ee-fc60-4e1d-a872-5d6776349d8e</guid><dc:creator>Yuval Mandel</dc:creator><description>&lt;p&gt;Seems To work, Thank you very much!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure where the other activity is coming from&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI driver implementation</title><link>https://devzone.nordicsemi.com/thread/275398?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 13:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91add61f-761d-4400-afed-45eaa335349c</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;My understanding is that the issue is that the slave select signal is toggled between the transmit and receive operation when you call&amp;nbsp;&lt;strong&gt;nrfx_spim_xfer&lt;/strong&gt;&lt;span&gt;&amp;nbsp;() with the tx and rx buffer. You can control the slave select pin yourself by using the GPIO driver. Just set the ss pin to&amp;nbsp;&lt;/span&gt;NRFX_SPIM_PIN_NOT_USED. You could then separate a tx and rx by calling the xfer twice. The psuedo code would look something like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set SS pin&lt;/li&gt;
&lt;li&gt;Call nrfx_spim_xfer(Set RX buffer to 0)&lt;/li&gt;
&lt;li&gt;Call &lt;span&gt;nrfx_spim_xfer(Set TX buffer to 0)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Clear SS pin.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Also, I think the image of the trace that you shared is a bit strange. Why is the there activity on the MOSI line and MISO line before the clock signal is active. Is there something else driving this line?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI driver implementation</title><link>https://devzone.nordicsemi.com/thread/275120?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 13:32:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52f93ead-731c-49f0-9a74-49b124e84c1e</guid><dc:creator>Yuval Mandel</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;First of all, I meant &amp;quot;&lt;strong&gt;nrfx_spim_xfer&amp;quot;&lt;/strong&gt;&lt;span&gt;&amp;nbsp; function, not &lt;strong&gt;&amp;quot;NRFX_SPIM_XFER_TRX&amp;quot;&lt;/strong&gt;, Sorry for the confusion.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Now, I&amp;#39;m seeing activities on the SPI signals. I used the &lt;strong&gt;nrfx_spim_xfer&lt;/strong&gt; function to read SPI slave device ID, and it worked fine as follows (some signals polarity is reversed, but it does work):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="359" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1602768179830v1.png" width="572" /&gt;&lt;/p&gt;
&lt;p&gt;(Green is SCLK, Blue is MOSI, Pink is MISO and yellow is the chip select)&lt;/p&gt;
&lt;p&gt;The problem is when I need the Transmit and the Receive data as two &lt;b&gt;separate&lt;/b&gt;&amp;nbsp;functions, because that is the way this specific device driver works:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="359" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1602768427940v2.png" width="572" /&gt;&lt;/p&gt;
&lt;p&gt;I think the problem might be that the chip select signal is going high at the end of each &lt;strong&gt;nrfx_spim_xfer&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;function call, so the device does not see it as a single action. Are there functions avaliable instead of &lt;strong&gt;nrfx_spim_xfer&lt;/strong&gt;&amp;nbsp;that can control those signals at a lower level? a function to lower chip select, a function to receive bytes, a function for transmit, etc? That will probably solve my issue.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(Sorry for the long time to reply, Had a problem viewing the signals on scope).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yuval&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI driver implementation</title><link>https://devzone.nordicsemi.com/thread/273680?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 09:40:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61f8f73c-95c2-4594-81e8-c6e5def237b6</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you be more specific of what exactly doesn&amp;#39;t work? Do you see any activities on the SPI lines?&amp;nbsp;If you&amp;#39;re going to use the the SPIM peripheral (SPI with Easy_DMA) then&amp;nbsp;you would use&amp;nbsp;NRFX_SPIM_XFER_TRX to set the buffers and&amp;nbsp;nrfx_spim_xfer_dcx() to actually start the transfer. Have you seen the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/nrfx_spim_example.html?cp=7_1_4_6_38"&gt;example&lt;/a&gt; in the SDK?&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Jared&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>