<?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: spi adc help</title>
		<link>http://forums.leaflabs.com/topic.php?id=974</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:17:27 +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=974" rel="self" type="application/rss+xml" />

		<item>
			<title>house91320 on "spi adc help"</title>
			<link>http://forums.leaflabs.com/topic.php?id=974#post-5996</link>
			<pubDate>Tue, 16 Aug 2011 13:10:42 +0000</pubDate>
			<dc:creator>house91320</dc:creator>
			<guid isPermaLink="false">5996@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;thanks ill let you guys know
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "spi adc help"</title>
			<link>http://forums.leaflabs.com/topic.php?id=974#post-5987</link>
			<pubDate>Mon, 15 Aug 2011 19:58:33 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5987@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;quick things to try:&#60;/p&#62;
&#60;p&#62;- replace Serial with SerialUSB, and delete the &#34;Serial.begin()&#34; line, as recommended here:&#60;/p&#62;
&#60;p&#62;  &#60;a href=&#34;http://leaflabs.com/docs/arduino-compatibility.html#sketch-and-library-porting-howto&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/arduino-compatibility.html#sketch-and-library-porting-howto&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;- delete the #include &#38;lt;SPI.h&#38;gt;, since there's no port for that library yet.  replace it with HardwareSPI, which is documented here:&#60;/p&#62;
&#60;p&#62;  &#60;a href=&#34;http://leaflabs.com/docs/lang/api/hardwarespi.html#lang-hardwarespi&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/lang/api/hardwarespi.html#lang-hardwarespi&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;  to get going quickly, i would just add the line &#60;code&#62;HardwareSPI SPI(1);&#60;/code&#62; before your setup(), since you appear to be using SPI1.  there are HardwareSPI methods which are equivalent to the SPI methods you're calling, so this should &#34;just work&#34;.&#60;/p&#62;
&#60;p&#62;everything else seems like it should be compatible between maple and arduino; let us know how you get along!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>house91320 on "spi adc help"</title>
			<link>http://forums.leaflabs.com/topic.php?id=974#post-5977</link>
			<pubDate>Fri, 12 Aug 2011 15:49:07 +0000</pubDate>
			<dc:creator>house91320</dc:creator>
			<guid isPermaLink="false">5977@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I was wondering if anyone could give me some help porting this to the maple?&#60;br /&#62;
#include &#38;lt;SPI.h&#38;gt;&#60;/p&#62;
&#60;p&#62;#define MISOPIN 12&#60;br /&#62;
#define SCLKPIN 13&#60;/p&#62;
&#60;p&#62;byte byte1; byte byte2; byte byte3;&#60;br /&#62;
// declare 3 bytes = 24 bits&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
  Serial.begin(9600);&#60;/p&#62;
&#60;p&#62;  pinMode(SCLKPIN, OUTPUT); pinMode(MISOPIN, INPUT);&#60;br /&#62;
  // corresponding to SCK pin and DRDY/DOUT pin on ADC&#60;/p&#62;
&#60;p&#62;  reset_adc();&#60;br /&#62;
  // put ADC on reset at the outset&#60;/p&#62;
&#60;p&#62;  SPI.begin();&#60;br /&#62;
  // initialize SPI (with default settings, including...&#60;br /&#62;
  // CPOL = 0: so that SCLK is normally LOW&#60;br /&#62;
  // CPHA = 0: data sampled on rising edge (LOW to HIGH)&#60;br /&#62;
  // perhaps try changing CPHA ??&#60;/p&#62;
&#60;p&#62;  digitalWrite(SCLKPIN, LOW);&#60;br /&#62;
  // release ADC from reset; now we're at a known point&#60;br /&#62;
  // in the timing diagram, and just have to wait for&#60;br /&#62;
  // the beginning of a conversion cycle&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop()&#60;br /&#62;
{&#60;br /&#62;
  if (digitalRead(MISOPIN) == HIGH) read_adc();&#60;br /&#62;
  // &#34;sort of&#34; an interrupt to go to read_adc routine;&#60;br /&#62;
  // can use hardware interrupt in future but now just poll&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void reset_adc()&#60;br /&#62;
// to reset ADC, we need SCLK HIGH for min of 4 CONVCYCLES&#60;br /&#62;
// so here, hold SCLK HIGH for 5 CONVCYCLEs = 1440 usec&#60;br /&#62;
{&#60;br /&#62;
  digitalWrite(SCLKPIN, HIGH);&#60;br /&#62;
  delayMicroseconds(1440);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void read_adc()&#60;br /&#62;
{&#60;br /&#62;
  drdy_wait();&#60;br /&#62;
  // go to drdy_wait routine, where we wait for&#60;br /&#62;
  // DRDY phase to pass, and thus for DOUT phase to begin&#60;/p&#62;
&#60;p&#62;  byte1 = SPI.transfer(0x00);&#60;br /&#62;
  byte2 = SPI.transfer(0x00);&#60;br /&#62;
  byte3 = SPI.transfer(0x00);&#60;br /&#62;
  // read in adc data (sending out don't care bytes)&#60;br /&#62;
  // and store read data into three bytes */&#60;/p&#62;
&#60;p&#62;  Serial.println(byte1, DEC);&#60;br /&#62;
  Serial.println(byte2, DEC);&#60;br /&#62;
  Serial.println(byte3, DEC);&#60;br /&#62;
  Serial.println();&#60;br /&#62;
  // print out data;&#60;br /&#62;
  // will these instructions eat into time significantly?&#60;br /&#62;
  // possible improvement: store all data from multiple cycles&#60;br /&#62;
  // into array, and print out only later at end.&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void drdy_wait()&#60;br /&#62;
// wait for DRDY to pass and to reach start-point of DOUT&#60;br /&#62;
{&#60;br /&#62;
  delayMicroseconds(30);&#60;br /&#62;
  // to be safe, 30 usec, instead of 27 usec, which is&#60;br /&#62;
  // the expected period of DRDY phase&#60;br /&#62;
}&#60;br /&#62;
thanks
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
