<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Hardware SPI = NSS</title>
		<link>http://forums.leaflabs.com/topic.php?id=1020</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:07:09 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=1020" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-8650</link>
			<pubDate>Thu, 15 Mar 2012 13:38:08 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">8650@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;hmm, seems like gbulmer might have figured this out finally. Spi.begin is obviously stealing NSS from you, and switching the output mode to alternate function output, which means the output is being controlled by a different peripheral from GPIO, in this case the SPI. Why the SPI peripheral is not controlling the pin properly is perhaps what gbulmer suggested, the SSOE bit is malconfigured. &#60;/p&#62;
&#60;p&#62;This could be a HardwareSpi bug...&#60;/p&#62;
&#60;p&#62;Either way, the workaround for now is to call pinMode on your NSS pin *after* calling spi.begin, and then toggling it manually.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>manitou on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-8615</link>
			<pubDate>Tue, 13 Mar 2012 19:05:51 +0000</pubDate>
			<dc:creator>manitou</dc:creator>
			<guid isPermaLink="false">8615@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;On an RET6 with IDE 0.0.12, I have been experimenting with setting NSS for external SPI device.  Ye ol arduino sketches and even the libmaple/examples/spi_master.c have pinMode(NSS,OUTPUT) and pull it high before invoking spi.begin.  But after the spi.begin, the NSS is no longer HIGH, and looking at the the port config registers, spi.begin has set the NSS pin to OUTPUT &#34;alternate function output push-pull&#34;. And setting the NSS pin high/low seems to have no effect (scope shows no activity). The only way I got the SPI sketches to work was to move the pinMode AFTER the spi.begin()&#60;/p&#62;
&#60;p&#62;Is there some other way one is supposed to control the NSS to activate SPI peripheral???
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6257</link>
			<pubDate>Fri, 09 Sep 2011 10:43:49 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">6257@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;robodude666 - Interesting. I guess it reduces the permutations of pins created by initialisation; it is always the same four pins effected.&#60;/p&#62;
&#60;p&#62;Try manipulting the SSOE bit. If that does what is needed, then a little warpper function would give that flexibility, and hide the mechanism.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6254</link>
			<pubDate>Fri, 09 Sep 2011 10:18:11 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">6254@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I honestly find this very interesting. The HardwareSPI class actually CONFIGURES the default NSS pin as an output for you, but it goes on with using software control (giving you control over it). It would be nice to see an update to HardwareSPI so you can give it the right to control NSS if your only planning on communicating to one device.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6251</link>
			<pubDate>Fri, 09 Sep 2011 10:06:35 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">6251@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;bdwyer - Please try robodude666 suggestion first.&#60;/p&#62;
&#60;p&#62;If that doesn't fix it, the RM0008 manual, section 25.3.1 &#34;General description&#34;, talks about the NSS pin being controlled by the SPI hardware when the SSOE bit is set.&#60;/p&#62;
&#60;p&#62;Would you print out the SSOE bit, which lives in the CR2 register:&#60;br /&#62;
&#60;code&#62;USBSerial.println((SPI1_BASE-&#38;gt;CR2) &#38;amp; 0b100, HEX);&#60;/code&#62;&#60;br /&#62;
You are looking to see what value the SSOE bit has. The SSOE bit is bit 2 (counting from bit 0), hence the &#60;code&#62;&#38;amp; 0b100&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;My reading is, when the SSOE bit is clear, the SPI hardware doesn't use it, so&#60;br /&#62;
&#60;code&#62;SPI1_BASE-&#38;gt;CR2 = SPI1_BASE-&#38;gt;CR2 &#38;amp; ~0b100;&#60;/code&#62;&#60;br /&#62;
should clear it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6247</link>
			<pubDate>Fri, 09 Sep 2011 09:29:33 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">6247@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I experienced &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=781&#34;&#62;similar&#60;/a&#62; issues before -- no matter what you did, the NSS pin never changed it's state after SPI was enabled. Unfortunately, I do not remember what I did to fix the issue.&#60;/p&#62;
&#60;p&#62;I believe in the end, I had the &#60;code&#62;pinMode&#60;/code&#62; set AFTER spi.begin was called, and I used &#60;code&#62;GPIO_OUTPUT_PP&#60;/code&#62; instead of &#60;code&#62;OUTPUT&#60;/code&#62;. Give it a try, maybe?&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bdwyer on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6237</link>
			<pubDate>Thu, 08 Sep 2011 23:55:06 +0000</pubDate>
			<dc:creator>bdwyer</dc:creator>
			<guid isPermaLink="false">6237@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm having an issue actually controlling the SS pin (pin 10). It seems that all use of this pin is diabled after using the function spi.begin(). Here is the code:&#60;/p&#62;
&#60;p&#62;HardwareSPI spi(1);&#60;br /&#62;
int slaveselectpin = 10;&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
  pinMode(slaveselectpin, OUTPUT);&#60;br /&#62;
  digitalWrite(slaveselectpin, HIGH);&#60;br /&#62;
  //delay(3000); I used this function so I could use a multimeter to witness pin 10 actually being set HIGH.&#60;br /&#62;
  spi.begin(SPI_281_250KHZ, MSBFIRST, 0); // As soon as this function is used, pin 10 goes low and never goes high during the loop sequence&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;void loop()&#60;br /&#62;
{&#60;/p&#62;
&#60;p&#62;digitalWrite(slaveselectpin, LOW);&#60;br /&#62;
  //delay(1);&#60;br /&#62;
  spi.write(255);&#60;br /&#62;
  digitalWrite(slaveselectpin, HIGH);&#60;br /&#62;
  delay(1000);//used this delay so I could see if pin 10 was going high at all&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;Any suggestions? It seems I lose control over pin 10...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6204</link>
			<pubDate>Tue, 06 Sep 2011 16:22:46 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">6204@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Yup. Hardware SPI will configure the GPIO as input/output for you, but it does not handle the select pin so that you can configure it to whichever one you wish to use. Checkout the &#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/master/examples/spi_master.cpp&#34;&#62;example&#60;/a&#62; on the github repo.&#60;/p&#62;
&#60;p&#62;Keep in mind that HardwareSPI will automatically always configure the SPI's default NSS/CS as an output - if you plan to use it as an input for something else, make sure to set the pinMode after SPI is configured.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bdwyer on "Hardware SPI = NSS"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1020#post-6202</link>
			<pubDate>Tue, 06 Sep 2011 15:55:42 +0000</pubDate>
			<dc:creator>bdwyer</dc:creator>
			<guid isPermaLink="false">6202@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm trying to use the Maple board for SPI on the CAN shield from sparkfun, and also another device called an IVT board (current/voltage/temperature sensor board).&#60;/p&#62;
&#60;p&#62;Anywho, I've rifled through the spi and hardwareSpi libraries and still am not sure if I need to setup the NSS function manually. If so, is it already implemented in the library(s) to do so:&#60;br /&#62;
example: &#60;/p&#62;
&#60;p&#62;hardwareSpi spi(1);&#60;br /&#62;
digitalWrite(spi.NSS,LOW);&#60;br /&#62;
spi.write(0);&#60;br /&#62;
digitalWrite(spi.NSS, HIGH);&#60;/p&#62;
&#60;p&#62;I am hoping this has a simple answer.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
