Hello everybody. I bought compass module CMPS03 produced by Devantech. It’s employs I2C bus. I wrote a program but it doesn’t work properly. I expect readings from 0 to 359 but I have from 65535 to 49279 and readings are jumping. I’m novice in I2C bus technology, and I can’t figure out what is the problem. If someone has experience with this module, please let me know where I made a mistake or at least point me on a good tutorial of I2C bus.
Thank you in advance
Vladimir

This is my code
'---------------- Definitions---------------------------------------------
define OSC 20
'------------- Define LCD registers and bits------------------------------
Define LCD_DREG PORTB 'Set LCD data port
Define LCD_DBIT 0 'Set starting data bit
Define LCD_RSREG PORTB 'Set LCD register select port
Define LCD_RSBIT 4 'Set LCD register select bit
Define LCD_EREG PORTB 'Set LCD enable port
Define LCD_EBIT 5 'Set LCD enable bit
define DEBUG_REG PORTC
DEFINE DEBUG_BIT 3
DEFINE DEBUG_BAUD 2400
DEFINE DEBUG_MODE 0



DPIN var PORTc.2 ' I2C data pin
CPIN var PORTc.1 ' I2C clock pin
bearing var word


Main
i2cread dpin,cpin,%11000000,1,[bearing]
lcdout $fe, 1,"Bearing ", # bearing
DEBUG " Compass Bearing ",DEC bearing,13,10

pause 200

goto main