I have tried this code over and over and everything else I can think of. Instead of getting back a temperature value I just get the slave address. Does anyone see a problem with this code? I am just trying to learn i2c. It seems simple. Here is the code.
Code:
'L3G4200D -MEMS motion sensor:ultra-stable three-axis digital output gyroscope
'datasheet at addy below
'http://www.parallax.com/portals/0/downloads/docs/prod/sens/27911-GyroscopeL3G4200DDatasheet.pdf
#picaxe 08m2
;Connections 08M2
;--Pin--Name----Function--------Remark------------------
; 1 +V Supply Voltage 5V
; 2 C.5 Serial In Not Used
; 3 C.4 Out Not Used
; 4 C.3 In Not Used
; 5 C.2 hi2c SDA I2C SDA
; 6 C.1 hi2c SCL I2C SCL
; 7 C.0 Serial Out Not Used
; 8 0V Ground 0V
;--------------------------------------------------------
Symbol GyroSlvAddr = 0xD3 'From datasheet
Symbol TempOutReg = 0x26 'From datasheet
Symbol CurrentTemp = b0 'definition
CurrentTemp = 0xaa 'init current temp to wierd value
pause 1000 'init time
hi2csetup i2cmaster,GyroSlvAddr,i2cfast,i2cbyte
'i2c setup Master 08m2
' Slave = L3G4200D gyro
'Datasheet: i2cfast (400khz) ok
' byte transfers
pause 50 '50ms delay just because
Do
hi2cin TempOutReg, (CurrentTemp) 'read the Temp Output Register
pause 1000 'temp updates at 1Hz
debug CurrentTemp 'display regs so I can see data
CurrentTemp = 0 'clear current temp
'Returns $d3 (GyroSlvAddr) in b0 %1101 0011
Loop
end