Trouble talking to HMC6364 Compass
I recently purchased this chip in hopes it would be simple to interface with the propeller. The documentation said in order to use the chip, I'd have to:
Sounds simple right? Yet no matter what I do I only am reading "0" as an output. Could someone please proof read my spin code and let me know if I am doing something really dumb?
I know there are objects to read this chip in the object exchange already, but I couldn't get them working either. Thanks in advance!
Using Basic I2C Routines Version 1.3
[FONT=sans-serif] 1. [/FONT][FONT=sans-serif]Appl[/FONT][FONT=sans-serif]y power to the VDD pins (nominally[/FONT] [FONT=sans-serif]2.[/FONT][FONT=sans-serif]Wait at least 5[/FONT][FONT=sans-serif]00[/FONT][FONT=sans-serif] milli[/FONT][FONT=sans-serif]-[/FONT][FONT=sans-serif]seconds for device initialization. The HMC6343 is in the default Run Mode.[/FONT] [FONT=sans-serif]3.[/FONT] [FONT=sans-serif]Send 0x32 and 0x50 to command the Heading and Tilt Data to be clocked out next.[/FONT] [FONT=sans-serif]4.[/FONT][FONT=sans-serif]Wait at least 1 milli[/FONT][FONT=sans-serif]-[/FONT][FONT=sans-serif]second[/FONT] [FONT=sans-serif]to allow the HMC6343 to process the comm[/FONT][FONT=sans-serif]and.[/FONT] [FONT=sans-serif]5.[/FONT][FONT=sans-serif]Send 0x33 and clock back six more response Bytes from the HMC6343. These will be the Heading, Pitch and [/FONT] [FONT=sans-serif]Roll Byte pairs[/FONT][FONT=sans-serif]; binary format in tenths of a degree[/FONT] [FONT=sans-serif]with 2s compliment on pitch and roll angles. (0 to 3600 [/FONT][FONT=sans-serif]heading, [/FONT] [FONT=sans-serif]±900 pitch, and ±9[/FONT][FONT=sans-serif]00 roll)[/FONT] [FONT=sans-serif]6.[/FONT][FONT=sans-serif]Repeat [/FONT][FONT=sans-serif]steps 3 [/FONT][FONT=sans-serif]-[/FONT][FONT=sans-serif]5 [/FONT][FONT=sans-serif]every 2[/FONT][FONT=sans-serif]00 milli[/FONT][FONT=sans-serif]-[/FONT][FONT=sans-serif]seconds or longer to ge[/FONT][FONT=sans-serif]t fresh data from the default 5[/FONT]Hz update rate
Sounds simple right? Yet no matter what I do I only am reading "0" as an output. Could someone please proof read my spin code and let me know if I am doing something really dumb?
CON
_clkmode=xtal1+pll16x
_xinfreq=5_000_000
device=$32 <<1
obj
serial : "Simple_Serial"
SN : "Simple_Numbers"
i2c : "Basic_I2C_Driver"
pub main|X
serial.init(1,30,4800)
waitcnt(clkfreq+cnt)
i2c.Initialize(22)'set our clock plus +1 for sda
waitcnt(clkfreq+cnt)
repeat
i2c.start(22)
i2c.Write(22,device)
i2c.Write(22,$50) 'get tilt heading info!
i2c.stop(22)
waitcnt(clkfreq/1000 + cnt) 'wait milisecond
i2c.start(22)
i2c.Write(22,$33)
X:=(i2c.Read(22,i2c#ACK) << 8) | (i2c.Read(22,i2c#ACK))
serial.str(SN.dec(X))
i2c.stop(22)
serial.str(string(" "))
waitcnt(clkfreq + cnt)
I know there are objects to read this chip in the object exchange already, but I couldn't get them working either. Thanks in advance!
Using Basic I2C Routines Version 1.3

Comments
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Magneto/HMC6343_v13.pdf
As for how its hooked up, scl is pin 22, and sda is pin 23. Data sheet is here: http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Missiles-Munitions/HMC6343.pdf
Now it prints this with out me touching the compass (stays stationary) so I know these are not proper heading values. If I run the code above using Tim Moore's clock stretching i2c driver I get all zeros. If it helps any I am using this breakout from spark fun https://www.sparkfun.com/products/8656 (so I am assuming I dont need pull up resistors since it works as is with an arduino).
CON _clkmode=xtal1+pll16x _xinfreq=5_000_000 device=$32 <<1 obj serial : "Simple_Serial" uarts : "Simple_Serial" SN : "Simple_Numbers" i2c : "Basic_I2C_Driver" i2cObject : "basic_i2c_driver" '0 COG hmc : "hmc6343object" VAR long i2cSCL pub main|X,Y,Z i2cSCL := 22 ' setup i2cObject i2cObject.Initialize(i2cSCL) uarts.init(1,30,4800) repeat hmc.GetHeading(i2cSCL, device,@X,@Y,@Z) uarts.str(string("Heading XYZ: ")) if X < 0 uarts.str(string("-")) uarts.str(SN.dec(||X/10)) uarts.str(string(".")) uarts.str(SN.dec(||X//10)) uarts.str(string(" ")) if Y < 0 uarts.str(string("-")) uarts.str(SN.dec((||Y)/10)) uarts.str(string(".")) uarts.str(SN.dec((||Y)//10)) uarts.str(string(" ")) if Z < 0 uarts.str(string("-")) uarts.str(SN.dec(||Z/10)) uarts.str(string(".")) uarts.str(SN.dec(||Z//10)) 'uarts.tx(0,13)This code returns only when tilted. if i move the compass, I get nothing but zeros again. I dont know what I am doing wrong, and the device itself works with my arduino uno, so I know the chip isn't bad. I've also tried using different pins on my prop for the i2c communication but that didn't give me different results either.