Other Parts Discussed in Thread: HALCOGEN, RM46L852, PCA9515
Hello,
I'm having difficulties communicating over I2C with a digital compass (HMC5883). I have I2C setup as follows in Halcogen (version 4.04 with the i2c set mode bug fix).
I'm using the following code to read register 10 on the HMC5883. For reference a link to the datasheet is given below.
www51.honeywell.com/.../HMC5883L_3-Axis_Digital_Compass_IC.pdf
#define HMC5883_ADDR 0x1E i2cInit(); i2cSetSlaveAdd(i2cREG1, HMC5883_ADDR); i2cSetDirection(i2cREG1, I2C_TRANSMITTER); i2cSetCount(i2cREG1, 1); i2cSetMode(i2cREG1, I2C_MASTER); i2cSetStop(i2cREG1); i2cSetStart(i2cREG1); i2cSendByte(i2cREG1, 0x10); while(i2cIsBusBusy(i2cREG1) == true); while(i2cIsStopDetected(i2cREG1) == 0); i2cClearSCD(i2cREG1); i2cSetSlaveAdd(i2cREG1, HMC5883_ADDR); i2cSetDirection(i2cREG1, I2C_RECEIVER); i2cSetCount(i2cREG1, 1); i2cSetMode(i2cREG1, I2C_MASTER); i2cSetStop(i2cREG1); i2cSetStart(i2cREG1); uint8 data = i2cReceiveByte(i2cREG1); while(i2cIsBusBusy(i2cREG1) == true); while(i2cIsStopDetected(i2cREG1) == 0); i2cClearSCD(i2cREG1);
The program never makes it out of the first
while(i2cIsBusBusy(i2cREG1) == true);
Any help would be appreciated, thanks.