<?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: New to Maple and having problems.</title>
		<link>http://forums.leaflabs.com/topic.php?id=121</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:12:16 +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=121" rel="self" type="application/rss+xml" />

		<item>
			<title>crenn on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121&amp;page=2#post-1222</link>
			<pubDate>Mon, 13 Sep 2010 18:25:32 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1222@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The code is now building, just need to test it now.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-1207</link>
			<pubDate>Mon, 13 Sep 2010 17:12:45 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1207@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;FYI the xl345 example code needs to have I2C_DELAY defined...oops&#60;/p&#62;
&#60;p&#62;try:&#60;/p&#62;
&#60;p&#62;#define I2C_DELAY delayMicroseconds(5)&#60;/p&#62;
&#60;p&#62;additionally all the _t style types should be switched to just uint8, int16, etc. And Usb.print should be swapped with SerialUSB.print. I told you this code was old!&#60;/p&#62;
&#60;p&#62;that should build...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>simon on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-792</link>
			<pubDate>Sun, 22 Aug 2010 19:09:26 +0000</pubDate>
			<dc:creator>simon</dc:creator>
			<guid isPermaLink="false">792@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am flashing it to RAM and the status LED was flashing normally when I plug it in.&#60;br /&#62;
Well, the blink code worked this time without making any changes. Not sure what caused the problem earlier...&#60;br /&#62;
will try some other sample programs and see&#60;br /&#62;
Anyways thanks Crenn :)&#60;/p&#62;
&#60;p&#62;-Simon
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-787</link>
			<pubDate>Sat, 21 Aug 2010 00:03:31 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">787@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@bnewbold, I tried casting it to just int but I did have to cast it to int16. I'm not sure why this is though, but it's enough for me to get going. I'm now curious if I do maths with it that it will see it as a negative number or a large positive number.&#60;/p&#62;
&#60;p&#62;@simon, Are you flashing to RAM or Flash? The blink code should be running fine. It should toggle the status LED (D13). Does the LED flash normally when you plug it in?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>simon on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-782</link>
			<pubDate>Fri, 20 Aug 2010 11:17:04 +0000</pubDate>
			<dc:creator>simon</dc:creator>
			<guid isPermaLink="false">782@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I have just started working on my Maple on a Windows7 32 bit platform. The drivers seem to be installed properly, looks like the code is uploaded to the Maple RAM also properly, however the code is not running. I just tried the simple blink code that is available in the examples.&#60;br /&#62;
this is what I got in the compiler window&#60;/p&#62;
&#60;p&#62;Searching for DFU device [1EAF:0003]...&#60;br /&#62;
Found it!&#60;/p&#62;
&#60;p&#62;Opening USB Device 0x1eaf:0x0003...&#60;br /&#62;
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=0, name=&#34;DFU Pro&#34;&#60;br /&#62;
Setting Configuration 1...&#60;br /&#62;
Claiming USB DFU Interface...&#60;br /&#62;
Setting Alternate Setting ...&#60;br /&#62;
Determining device status: state = dfuIDLE, status = 0&#60;br /&#62;
dfuIDLE, continuing&#60;br /&#62;
Transfer Size = 0x0400&#60;br /&#62;
bytes_per_hash=222&#60;br /&#62;
Starting download: [##################################################] finished!&#60;br /&#62;
error resetting after download: usb_reset: could not reset device, win error: The system cannot find the file specified.&#60;br /&#62;
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present&#60;/p&#62;
&#60;p&#62;Done!&#60;/p&#62;
&#60;p&#62;Resetting USB to switch back to runtime mode&#60;/p&#62;
&#60;p&#62;Meanwhile the status LED goes off at this time, is that normal?&#60;br /&#62;
Could you tell me what I could do to get it working?&#60;/p&#62;
&#60;p&#62;Thanks
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bnewbold on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-770</link>
			<pubDate>Thu, 19 Aug 2010 10:58:48 +0000</pubDate>
			<dc:creator>bnewbold</dc:creator>
			<guid isPermaLink="false">770@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;crenn, I'm guessing what's happening is that you are recieving is a signed value over SPI but it's being treated as raw unsigned data. You will need to cast it from raw values to a signed variable type. For instance, this code:&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
uint16 raw = 64876;&#60;/p&#62;
&#60;p&#62;void setup() { }&#60;/p&#62;
&#60;p&#62;void loop() {&#60;br /&#62;
  SerialUSB.print(&#34;raw = &#34;);&#60;br /&#62;
  SerialUSB.println(raw,DEC);&#60;br /&#62;
  SerialUSB.print(&#34;cast = &#34;);&#60;br /&#62;
  SerialUSB.println((int16)raw,DEC);&#60;br /&#62;
  delay(1000);&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;gives this output:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
raw = 64876&#60;br /&#62;
cast = -660&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-762</link>
			<pubDate>Wed, 18 Aug 2010 16:26:10 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">762@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Good to know, 64876 is clearly a signed value thing. When I do:&#60;/p&#62;
&#60;p&#62;int x = -1;&#60;br /&#62;
SerialUSB.println(x);&#60;/p&#62;
&#60;p&#62;I get the ascii string &#34;-1&#34; on the other end out the virtual com port. Is this not the case for you? You should just be able to do:&#60;br /&#62;
int x = xl345ReadVal();&#60;br /&#62;
SerialUSB.println(x) ...&#60;/p&#62;
&#60;p&#62;perhaps theres something weird going on with conversions in the function tree, for example, if read the raw bytes out of an i2c/spi pipe, there are a few ways to get this into your final &#34;int&#34; for printing. &#60;/p&#62;
&#60;p&#62;The most straightfoward, with the least use of syntax (although the most verbose) is:&#60;/p&#62;
&#60;p&#62;(xl345 vals are stored in two registers)&#60;br /&#62;
uint8 highNibble = xl345Read(ADDR_HIGH);&#60;br /&#62;
uint8 lowNibble  = xl345Read(ADDR_LOW);&#60;/p&#62;
&#60;p&#62;int value = lowNibble + ((highNibble &#38;amp; 0x7F) &#38;lt;&#38;lt; 8) - ((highNibble &#38;amp; 0x80) &#38;lt;&#38;lt; 8);&#60;/p&#62;
&#60;p&#62;thus manually doing the signed conversion and what not. Obviously C has syntax to this for you via casting. I would probably do something like this:&#60;/p&#62;
&#60;p&#62;uint8 readBuf[2];&#60;br /&#62;
readBuf[0] = xl345Read(ADDR_LOW);&#60;br /&#62;
readBuf[1] = xl345Read(ADDR_HIGH);&#60;/p&#62;
&#60;p&#62;int16 value = *(int16*)readBuf;&#60;/p&#62;
&#60;p&#62;Probably the best way to do it is with unions. But I like the above way better. &#60;/p&#62;
&#60;p&#62;Then SerialUSB.print(value) should give you the negative properly.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-753</link>
			<pubDate>Tue, 17 Aug 2010 15:15:08 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">753@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Currently the ranges are from -4096 to 4096. How do I know this? When I move the sensor so no force (in this case gravity) is acting on an Axis, it's reading approxiamately 0. If I move it so it's upside down, SerialUSB.print(...) is telling me 64876 (not an actual value, but a representation of what I'm saying) which in dicates 2's complement.&#60;/p&#62;
&#60;p&#62;There is the range bits, the Justify bits and full Res bits in the DATA_FORMAT register. Justify bit:&#60;br /&#62;
&#34;A setting of 1 in the justify bit selects left (MSB) justified mode, and a setting of 0 selects right justified mode with sign extension.&#34;&#60;br /&#62;
This is set to 0 in my code. Range has been set to full and full res has been set to 1.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-750</link>
			<pubDate>Tue, 17 Aug 2010 14:06:21 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">750@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Awesome that you got the actual spi library working instead of that bit banged junk i sent you! &#60;/p&#62;
&#60;p&#62;Id have to check the datasheet for the xl345 about the output formatting, but Im fairly certain if you SerialUSB.print(int x) a signed int or decimal it will print with the appropriate formatting via polymorphic typechecking in c++. You might have tweak the output from the 345 to actually get a zero centered value though - what is the formatting there? I remember you could choose betwee left or right justified, and you could choose the LSB scale factor, but I dont recall anything about signed output.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-745</link>
			<pubDate>Sat, 14 Aug 2010 06:34:15 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">745@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Sorry for triple posting, but this is what I've ended up with for the ADXL SPI Code.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.crennsmind.com/Code/Maple/SPI/ADXL345-Code.txt&#34; rel=&#34;nofollow&#34;&#62;http://www.crennsmind.com/Code/Maple/SPI/ADXL345-Code.txt&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;What I got over USB before I finialised the code:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.crennsmind.com/Code/Maple/SPI/ADXL345-ExampleOutput.txt&#34; rel=&#34;nofollow&#34;&#62;http://www.crennsmind.com/Code/Maple/SPI/ADXL345-ExampleOutput.txt&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I'm wondering if it's possible to get Serial to not print everything as unsigned so I can see the negative numbers.&#60;/p&#62;
&#60;p&#62;I'd still like to get I2C working, but this gets me to a stage where I can use this sensor.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-744</link>
			<pubDate>Sat, 14 Aug 2010 01:37:41 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">744@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well, I can't seem to get that code working poslathian. I'm not sure why currently.&#60;/p&#62;
&#60;p&#62;Here's the state of code after trying to fiddle with it for a while:&#60;/p&#62;
&#60;p&#62;[code]&#60;br /&#62;
// ADXL345 I2C software&#60;/p&#62;
&#60;p&#62;#define XL_SCL 6&#60;br /&#62;
#define XL_SDA 7&#60;br /&#62;
#define XL_READ_ADDR 0xA7&#60;br /&#62;
#define XL_WRITE_ADDR 0xA6&#60;/p&#62;
&#60;p&#62;#define I2C_DELAY delayMicroseconds(200);&#60;/p&#62;
&#60;p&#62;static void i2c_start() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,LOW);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_stop() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_send_ack() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,LOW);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static int i2c_get_ack() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;/p&#62;
&#60;p&#62;  for (int i=100;i&#38;gt;0;i--) {&#60;br /&#62;
    if (!gpio_read_bit(GPIOB_BASE,XL_SDA)) {&#60;br /&#62;
      I2C_DELAY&#60;br /&#62;
      I2C_DELAY&#60;br /&#62;
      gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
      return 1;&#60;br /&#62;
    }&#60;br /&#62;
  }&#60;br /&#62;
  return 0;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_send_nack() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_shift_out(uint8_t val) {&#60;br /&#62;
  for (int i=0;i&#38;lt;8;i++) {&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SDA, (val &#38;amp; (1 &#38;lt;&#38;lt; (7 - i))));&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL, HIGH);&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL, LOW);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;static uint8_t i2c_shift_in() {&#60;br /&#62;
  uint8_t data;&#60;/p&#62;
&#60;p&#62;  for (int i=0;i&#38;lt;8;i++) {&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    data += gpio_read_bit(GPIOB_BASE,XL_SDA) &#38;lt;&#38;lt; (7-i);&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  return data;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_write(uint8_t addr, uint8_t val) {&#60;br /&#62;
  /*&#60;br /&#62;
  1) start&#60;br /&#62;
  2) dev addr write&#60;br /&#62;
  3) ack&#60;br /&#62;
  4) reg addr&#60;br /&#62;
  5) ack&#60;br /&#62;
  6) data&#60;br /&#62;
  7) ack&#60;br /&#62;
  8) stop&#60;br /&#62;
  */&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_WRITE_ADDR);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(addr);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(val);&#60;br /&#62;
  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_stop();&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t i2c_read(uint8_t addr) {&#60;br /&#62;
  /*&#60;br /&#62;
  1) start&#60;br /&#62;
  2) slave addr write&#60;br /&#62;
  3) ack&#60;br /&#62;
  4) reg addr&#60;br /&#62;
  5) ack&#60;br /&#62;
  6) start&#60;br /&#62;
  7) slave addr read&#60;br /&#62;
  8) ack&#60;br /&#62;
  9) data in&#60;br /&#62;
  10) nack&#60;br /&#62;
  11) stop&#60;br /&#62;
  */&#60;/p&#62;
&#60;p&#62;  uint8_t data;&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_WRITE_ADDR);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(addr);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_READ_ADDR);&#60;br /&#62;
  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  data = i2c_shift_in();&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;/p&#62;
&#60;p&#62;  i2c_send_nack();&#60;br /&#62;
  i2c_stop();&#60;br /&#62;
  return data;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint16_t i2c_read16(uint8_t addr) {&#60;br /&#62;
  /*&#60;br /&#62;
  1) start&#60;br /&#62;
  2) slave addr write&#60;br /&#62;
  3) ack&#60;br /&#62;
  4) reg addr&#60;br /&#62;
  5) ack&#60;br /&#62;
  6) start&#60;br /&#62;
  7) slave addr read&#60;br /&#62;
  8) ack&#60;br /&#62;
  9) data in&#60;br /&#62;
  10) ack&#60;br /&#62;
  ... 9)&#60;br /&#62;
  12) nack&#60;br /&#62;
  13) stop&#60;br /&#62;
  */&#60;br /&#62;
  uint16_t data;&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_WRITE_ADDR);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(addr);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_READ_ADDR);&#60;br /&#62;
  if (!i2c_get_ack()) {&#60;br /&#62;
    SerialUSB.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  data = i2c_shift_in();&#60;/p&#62;
&#60;p&#62;  i2c_send_ack();&#60;/p&#62;
&#60;p&#62;  data = i2c_shift_in()&#38;lt;&#38;lt;8;&#60;br /&#62;
  i2c_send_nack();&#60;br /&#62;
  i2c_stop();&#60;br /&#62;
  return data;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;/******* xl345 ******/&#60;br /&#62;
void xl345_init() {&#60;br /&#62;
  i2c_write(0x2C,0x0A);&#60;br /&#62;
  i2c_write(0x2D,0x08);&#60;br /&#62;
  i2c_write(0x31,0x04);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t xl345_readX() {&#60;br /&#62;
  int8_t val = (int8_t)i2c_read(0x33);&#60;br /&#62;
  val += 128;&#60;br /&#62;
  return (uint8_t) val;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t xl345_readY() {&#60;br /&#62;
  int8_t val = (int8_t)i2c_read(0x35);&#60;br /&#62;
  val += 128;&#60;br /&#62;
  return (uint8_t) val;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t xl345_readZ() {&#60;br /&#62;
  int8_t val = (int8_t)i2c_read(0x37);&#60;br /&#62;
  val += 128;&#60;br /&#62;
  return (uint8_t) val;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
  // start serial port at 9600 bps:&#60;br /&#62;
  //SerialUSB.begin(9600);&#60;br /&#62;
  pinMode(LED_PIN, OUTPUT);&#60;br /&#62;
  SerialUSB.println(&#34;Set mode&#34;);&#60;/p&#62;
&#60;p&#62;  xl345_init();&#60;br /&#62;
  SerialUSB.println(&#34;Initialization finished&#34;);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop()&#60;br /&#62;
{&#60;br /&#62;
  byte value=0;&#60;br /&#62;
  byte state=HIGH;&#60;br /&#62;
  value=(int8_t)i2c_read(0x00);&#60;br /&#62;
  SerialUSB.println(value, HEX);&#60;br /&#62;
  digitalWrite(LED_PIN, state);&#60;br /&#62;
  delay(500);&#60;br /&#62;
  state^=HIGH;&#60;br /&#62;
}&#60;br /&#62;
[/code]&#60;/p&#62;
&#60;p&#62;And here is what appears when I try to compile:&#60;br /&#62;
[code]&#60;br /&#62;
Going to build using 'make' (ARM)&#60;br /&#62;
	Compiling core...&#60;br /&#62;
	Compiling any libs...&#60;br /&#62;
	Compiling the sketch...&#60;/p&#62;
&#60;p&#62;error: variable or field 'i2c_shift_out' declared voidBad error line: -2&#60;br /&#62;
[/code]&#60;/p&#62;
&#60;p&#62;EDIT: I think I may have an idea why SPI isn't working. The clock remains low instead of staying high.&#60;/p&#62;
&#60;p&#62;EDIT2: SPI mode is always 0. In HardwareSPI.cpp, in function void HardwareSPI::begin, line 105, the line is:&#60;br /&#62;
spi_init(spi_num, prescale, endianness, 0);&#60;br /&#62;
It should be:&#60;br /&#62;
spi_init(spi_num, prescale, endianness, mode);&#60;/p&#62;
&#60;p&#62;Since changing that line, the SPI is working with the ADXL345 and I'm getting a DeviceID of E5 which is what I'm expecting!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-743</link>
			<pubDate>Fri, 13 Aug 2010 20:09:55 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">743@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@bnewbold&#60;br /&#62;
I'm currently running Windows 7 32-bit. But I have access to Windows XP SP3, Windows 7 64-bit. And a Linux based NAS I can SSH into. I also soon will have access to an Android/Linux tablet which has a USB port. I'm thinking of maybe trying to get that to communicate with the Maple and the Maple to act as I/O for the tablet.&#60;/p&#62;
&#60;p&#62;I do have a level translator (I used one when I was using an Arduino to try to communicate with the ADXL345) and it uses Open Drain as well. Using timers and output compare (I think it's that, it's been a long time) isn't an issue since I used to have to do that for one of my university subjects. I'm also aware of the interrupt issues and can probably work around it.&#60;/p&#62;
&#60;p&#62;@poslathian&#60;br /&#62;
I'll work on porting that code to the new libmaple libraries today. I suspect this sensor is dead, but I'm not 100% sure. I might try with my Arduino again since I was getting a response, just the responses didn't make sense.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-742</link>
			<pubDate>Fri, 13 Aug 2010 14:09:03 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">742@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;you can see how dated this code is via the Usb.print instead of SerialUSB.print ... heh
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-741</link>
			<pubDate>Fri, 13 Aug 2010 14:08:27 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">741@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;A long time ago, when we had no i2c library, I did a bit banged interface to an xl345 which worked just fine. The xl345 has a few interface modes, as im sure you know, I2C address 0, I2C address 1, and SPI 3 wire, and SPI 4 wire. The 3 versus 4 wire spi is selected by some spi write transaction and then i2c address and i2c versus spi is selected (IIRC) by setting or resetting some sel pins. &#60;/p&#62;
&#60;p&#62;anyway, heres a code dump of a working xl345 i2c interface, I'll try and dig up a schematic, since the i2c lines are pulled up and configured to open drain. Ill take a closer look at your code and see if I see anything. &#60;/p&#62;
&#60;p&#62;/******* i2c ********/&#60;br /&#62;
#define XL_SCL          6&#60;br /&#62;
#define XL_SDA          7&#60;br /&#62;
#define XL_READ_ADDR    0xA7&#60;br /&#62;
#define XL_WRITE_ADDR   0xA6&#60;/p&#62;
&#60;p&#62;static void i2c_start() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,LOW);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_stop() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_send_ack() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,LOW);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static int i2c_get_ack() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;/p&#62;
&#60;p&#62;  for (int i=100;i&#38;gt;0;i--) {&#60;br /&#62;
    if (!gpio_read_bit(GPIOB_BASE,XL_SDA)) {&#60;br /&#62;
      I2C_DELAY&#60;br /&#62;
      I2C_DELAY&#60;br /&#62;
      gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
      return 1;&#60;br /&#62;
    }&#60;br /&#62;
  }&#60;br /&#62;
  return 0;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_send_nack() {&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SDA,HIGH);&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_shift_out(uint8_t val) {&#60;br /&#62;
  for (int i=0;i&#38;lt;8;i++) {&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SDA, !!(val &#38;amp; (1 &#38;lt;&#38;lt; (7 - i))));&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL, HIGH);&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL, LOW);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;static uint8_t i2c_shift_in() {&#60;br /&#62;
  uint8_t data;&#60;/p&#62;
&#60;p&#62;  for (int i=0;i&#38;lt;8;i++) {&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL,HIGH);&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    data += gpio_read_bit(GPIOB_BASE,XL_SDA) &#38;lt;&#38;lt; (7-i);&#60;br /&#62;
    I2C_DELAY&#60;br /&#62;
    gpio_write_bit(GPIOB_BASE,XL_SCL,LOW);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  return data;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static void i2c_write(uint8_t addr, uint8_t val) {&#60;br /&#62;
  /*&#60;br /&#62;
    1) start&#60;br /&#62;
    2) dev addr write&#60;br /&#62;
    3) ack&#60;br /&#62;
    4) reg addr&#60;br /&#62;
    5) ack&#60;br /&#62;
    6) data&#60;br /&#62;
    7) ack&#60;br /&#62;
    8) stop&#60;br /&#62;
  */&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_WRITE_ADDR);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(addr);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(val);&#60;br /&#62;
  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_stop();&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t i2c_read(uint8_t addr) {&#60;br /&#62;
  /*&#60;br /&#62;
    1) start&#60;br /&#62;
    2) slave addr write&#60;br /&#62;
    3) ack&#60;br /&#62;
    4) reg addr&#60;br /&#62;
    5) ack&#60;br /&#62;
    6) start&#60;br /&#62;
    7) slave addr read&#60;br /&#62;
    8) ack&#60;br /&#62;
    9) data in&#60;br /&#62;
    10) nack&#60;br /&#62;
    11) stop&#60;br /&#62;
  */&#60;/p&#62;
&#60;p&#62;  uint8_t data;&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_WRITE_ADDR);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(addr);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_READ_ADDR);&#60;br /&#62;
  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  data = i2c_shift_in();&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;br /&#62;
  I2C_DELAY&#60;/p&#62;
&#60;p&#62;  i2c_send_nack();&#60;br /&#62;
  i2c_stop();&#60;br /&#62;
  return data;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint16_t i2c_read16(uint8_t addr) {&#60;br /&#62;
  /*&#60;br /&#62;
    1) start&#60;br /&#62;
    2) slave addr write&#60;br /&#62;
    3) ack&#60;br /&#62;
    4) reg addr&#60;br /&#62;
    5) ack&#60;br /&#62;
    6) start&#60;br /&#62;
    7) slave addr read&#60;br /&#62;
    8) ack&#60;br /&#62;
    9) data in&#60;br /&#62;
    10) ack&#60;br /&#62;
    ... 9)&#60;br /&#62;
    12) nack&#60;br /&#62;
    13) stop&#60;br /&#62;
  */&#60;br /&#62;
  uint16_t data;&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_WRITE_ADDR);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_shift_out(addr);&#60;/p&#62;
&#60;p&#62;  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  i2c_start();&#60;br /&#62;
  i2c_shift_out(XL_READ_ADDR);&#60;br /&#62;
  if (!i2c_get_ack()) {&#60;br /&#62;
    Usb.println(&#34;Missed i2c ack!&#34;);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  data = i2c_shift_in();&#60;/p&#62;
&#60;p&#62;  i2c_send_ack();&#60;/p&#62;
&#60;p&#62;  data = i2c_shift_in()&#38;lt;&#38;lt;8;&#60;br /&#62;
  i2c_send_nack();&#60;br /&#62;
  i2c_stop();&#60;br /&#62;
  return data;&#60;br /&#62;
} &#60;/p&#62;
&#60;p&#62;/******* xl345 ******/&#60;br /&#62;
void xl345_init() {&#60;br /&#62;
  i2c_write(0x2C,0x0A);&#60;br /&#62;
  i2c_write(0x2D,0x08);&#60;br /&#62;
  i2c_write(0x31,0x04);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t xl345_readX() {&#60;br /&#62;
  int8_t val = (int8_t)i2c_read(0x33);&#60;br /&#62;
  val += 128;&#60;br /&#62;
  return (uint8_t) val;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t xl345_readY() {&#60;br /&#62;
  int8_t val = (int8_t)i2c_read(0x35);&#60;br /&#62;
  val += 128;&#60;br /&#62;
  return (uint8_t) val;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;static uint8_t xl345_readZ() {&#60;br /&#62;
  int8_t val = (int8_t)i2c_read(0x37);&#60;br /&#62;
  val += 128;&#60;br /&#62;
  return (uint8_t) val;&#60;br /&#62;
}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bnewbold on "New to Maple and having problems."</title>
			<link>http://forums.leaflabs.com/topic.php?id=121#post-738</link>
			<pubDate>Fri, 13 Aug 2010 11:25:57 +0000</pubDate>
			<dc:creator>bnewbold</dc:creator>
			<guid isPermaLink="false">738@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hey crenn, I'll have to look at the SPI stuff over the weekend.&#60;/p&#62;
&#60;p&#62;I'm actually rewriting the i2c code right now, I can send you my work tomorrow or sunday; if you tell me what platform you're running i'll put up an IDE build with the changes to libmaple integrated.&#60;/p&#62;
&#60;p&#62;I don't think it's possible to do PWM as open drain, I tried to do the same to drive a 3 color LED. I've had success just running simple servos at 3.3v (with 5v power) and H-bridge-type circuits work just at proportionally lower maximum power (eg, these circuits are measuring the average voltage, so the max with 3.3v will be 3.3/5 or about 70%). Two solutions to this problem are to use an external level converter or to use the Timer functionality to enable/disable GPIO pins. The later could be glitchy if other interrupts take precidence (eg, SysTick or USB). We're going to set up proper interrupt priorities to prevent these issues, but not in the next few weeks.&#60;/p&#62;
&#60;p&#62;It's also possible that PWM /can/ be configured with different pin modes and that I just didn't figure it out.&#60;/p&#62;
&#60;p&#62;Hope that helps!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
