<?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>nrf9160-dk spi clock configuration problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72857/nrf9160-dk-spi-clock-configuration-problem</link><description>I made an own SPI device driver using the SDK&amp;#39;s BM280 as a pattern 
 The result has a strange clock configuration (normally high - should be normally low) 
 
 Looking through other SPI drivers I do not see where this is coming from. 
 Is there an example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 20 Mar 2021 10:30:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72857/nrf9160-dk-spi-clock-configuration-problem" /><item><title>RE: nrf9160-dk spi clock configuration problem</title><link>https://devzone.nordicsemi.com/thread/301038?ContentTypeID=1</link><pubDate>Sat, 20 Mar 2021 10:30:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39065c27-0d37-461a-b7fc-8311766ee29a</guid><dc:creator>paul_tanner</dc:creator><description>&lt;p&gt;Many thx Hakon,&lt;/p&gt;
&lt;p&gt;That example was what I needed to properly configure the CS pin.&lt;/p&gt;
&lt;p&gt;(I still have an issue of compatibility with an alternative app for nrf52 but that&amp;#39;s a separate matter.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf9160-dk spi clock configuration problem</title><link>https://devzone.nordicsemi.com/thread/301001?ContentTypeID=1</link><pubDate>Fri, 19 Mar 2021 16:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a01e21cb-e56b-4998-acf6-c789e86f8d47</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;you can look at this sample &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7167.spi_5F00_test.zip"&gt;devzone.nordicsemi.com/.../7167.spi_5F00_test.zip&lt;/a&gt;. It shows the correct configurations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf9160-dk spi clock configuration problem</title><link>https://devzone.nordicsemi.com/thread/300417?ContentTypeID=1</link><pubDate>Wed, 17 Mar 2021 13:09:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1db877d-0465-4768-b07d-471f05e9e231</guid><dc:creator>paul_tanner</dc:creator><description>&lt;p&gt;I was using&amp;nbsp; SPI_TRANSFER_MSB | SPI_MODE_CPHA | SPI_MODE_CPOL&lt;/p&gt;
&lt;p&gt;I have removed the last 2 of these 3 which seemed to improve the clock waveform.&amp;nbsp; But what does&amp;nbsp;&lt;span&gt;SPI_MODE_CPHA mean and where can one look up this sort of thing?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I found this in&amp;nbsp;/ncs/zephyr/include/drivers/spi.h but can&amp;#39;t say I understand it all.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SPI_LINES_DUAL sounds interesting as I will need 2 devices connected by SPI&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Anyway, I simplified my main.c so it just calls&amp;nbsp;sensor_sample_fetch&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;At this point I see cs going low and staying low.&amp;nbsp; No activity on the other 3 pins.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I restored&amp;nbsp;SPI_MODE_CPHA | SPI_MODE_CPOL and this gets me back to where I started but the device I&amp;#39;m working with needs a normally low clock.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Finally, I took out all the config bits.&amp;nbsp; This then produces something that looks correct.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; Additionally, the CS pin does not change.&amp;nbsp; It should go low when an SPI transfer takes place.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Excerpt from board overlay&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;&amp;amp;spi2 {&lt;br /&gt; compatible = &amp;quot;nordic,nrf-spim&amp;quot;;&lt;br /&gt; status = &amp;quot;okay&amp;quot;;&lt;br /&gt; sck-pin = &amp;lt;19&amp;gt;;&lt;br /&gt; mosi-pin = &amp;lt;18&amp;gt;;&lt;br /&gt; miso-pin = &amp;lt;17&amp;gt;;&lt;br /&gt; cs-gpios = &amp;lt;&amp;amp;gpio0 16 GPIO_ACTIVE_LOW&amp;gt;;&lt;br /&gt; &lt;br /&gt; buggyair@16 {&lt;br /&gt;   compatible = &amp;quot;buggyair,ss3&amp;quot;;&lt;br /&gt;&lt;/span&gt;   status = &amp;quot;okay&amp;quot;;&lt;br /&gt;   reg = &amp;lt;0x00&amp;gt;;&lt;br /&gt;   spi-max-frequency = &amp;lt;4000000&amp;gt;;&lt;br /&gt;   label = &amp;quot;BUGGYAIR&amp;quot;;&lt;br /&gt; };&lt;br /&gt;};&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;device constructor&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;/*&lt;br /&gt;#define SS3 DT_INST(0, buggyair_ss3)&lt;br /&gt;#if DT_NODE_HAS_STATUS( SS3, okay)&lt;br /&gt;#define DEV_LABEL DT_LABEL(SS3)&lt;br /&gt;#else&lt;br /&gt;#error Your devicetree has no enabled nodes with compatible &amp;quot;buggyair,ss3&amp;quot;&lt;br /&gt;#define DEV_LABEL &amp;quot;&amp;lt;none&amp;gt;&amp;quot;&lt;br /&gt;#endif&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;#define DEV_LABEL &amp;quot;SPI_2&amp;quot;&lt;br /&gt;const struct device *source = device_get_binding(DEV_LABEL);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:inherit;"&gt;The original device constructor caused an immediate crash. Replacing this with &amp;quot;SPI_2&amp;quot;&lt;br /&gt;makes it run but, understandably nothing happens on PO.16&lt;br /&gt;&lt;br /&gt;Any advice appreciated.&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>