Other Parts Discussed in Thread: HDC1080
Hello,
I have been trying to get some measurements from a HDC1080 in Sensor Controller Studio but no success. I've followed the ALS I2C example and looked at others with similar problems on the forums but I haven't found a solution yet.
Could someone please take a look at the code and tell me if I'm doing anything wrong? I'm fairly new to this so it may be something very simple.
I've done a quick check of the voltage levels and they seem OK, however I don't have a logic analyzer to go any further.
When I run the Task Tester, the Humidity value goes to 1 and i2cStatus also goes to 1 and then stays there.
Configuration register is left as default.
// Trigger temperature read i2cStart(); i2cTx(PMOD_I2C_ADDR | I2C_OP_WRITE); // 0x0040 << 1 i2cTx(PMOD_REG_TEMP); // 0x0000 fwDelayUs(15000,FW_DELAY_RANGE_20_MS); // Conversion time of temperature and humidity measurement // Read temperature value, then humidity if (state.i2cStatus == 0) { U16 TEMP_MSB; U16 TEMP_LSB; U16 HUM_MSB; U16 HUM_LSB; i2cRepeatedStart(); i2cTx(PMOD_I2C_ADDR | I2C_OP_READ); // 0x0040 << 1 i2cRxAck(TEMP_MSB); i2cRxAck(TEMP_LSB); i2cRxAck(HUM_MSB); i2cRxNack(HUM_LSB); i2cStop(); U16 TEMP_RESULT; U16 HUM_RESULT; TEMP_RESULT = (TEMP_MSB << 8) | TEMP_LSB; HUM_RESULT = (HUM_MSB << 8) | HUM_LSB; output.tempResult = TEMP_RESULT; output.humResult = HUM_RESULT; } else { i2cStop(); } i2cStop(); // Run-time logging: Log the output data structure rtlLogStructs(BV_RTL_LOG_OUTPUT); // Schedule the next execution fwScheduleTask(1);
Thanks!
Mike