Other Parts Discussed in Thread: HDC1000, CC2650
Tool/software: TI-RTOS
Hi,
I am unable to communicate via i2c to the humidity sensor on the SensorTag. I have successfully got communications flowing with the accelerometer, infrared sensor, pressure sensor and light sensor. I have tried this code with two different sensortags and two different debuggers (XDS110 DEVPACK), so I dont think it is the hardware to blame.
The following code was based on the i2ctmp007_CC2650STK_TI example project. the only lines changed are:
txBuffer[0] = 0xfe
i2cTransaction.slaveAddress = Board_HDC1000_ADDR; /* 0x43 */
Here is a sample of the file involving the i2c communications function.
#define MANUFACTURER_REG 0xfe
Void taskFxn(UArg arg0, UArg arg1) { uint16_t id; uint8_t txBuffer[1]; uint8_t rxBuffer[2]; I2C_Handle i2c; I2C_Params i2cParams; I2C_Transaction i2cTransaction; /* Create I2C for usage */ I2C_Params_init(&i2cParams); i2cParams.bitRate = I2C_400kHz; i2c = I2C_open(Board_I2C_TMP, &i2cParams); if (i2c == NULL) { System_abort("Error Initializing I2C\n"); } else { System_printf("I2C Initialized!\n"); } /* Point to the T ambient register and read its 2 bytes */ txBuffer[0] = MANUFACTURER_REG; /* 0xfe */ i2cTransaction.slaveAddress = Board_HDC1000_ADDR; /* 0x43 */ i2cTransaction.writeBuf = txBuffer; i2cTransaction.writeCount = 1; i2cTransaction.readBuf = rxBuffer; i2cTransaction.readCount = 2; if (I2C_transfer(i2c, &i2cTransaction)) { /* Extract degrees C from the received data; see TMP102 datasheet */ id = (rxBuffer[0] << 8) | rxBuffer[1]; System_printf("ID %d\n", id); } else { System_printf("I2C Bus fault\n"); } /* Deinitialized I2C */ I2C_close(i2c); System_printf("I2C closed!\n"); System_flush(); }
The output of this program is:
I2C Initialized!
I2C Bus fault
I2C closed!
Any ideas ?