This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: WEBENCH® Design Tools
Hi,
I am trying out my code on HDC 1010. I have set the register 0x02 like this…
wr_data[0] = (1 << 4);
wr_data[1] = 0x00;
When I tried to poll DRDYn pin, it just doesn’t want come down. Hence I can’t read the temperature and humidity values.
Do you know what goes wrong? Do I miss out anything?
Regards,
Nelson
Hi Josh,
Thanks for coming back.
Would like to ask you. If I put a pull-up resistor of 1.5k to the DRDYn pin and my code is as below, is there anything wrong that stops the DRDYn pin to be pulled low? It always gets stuck at while(HDC1010_DRDYN_PIN.read());, which doesn't go low.
The slvAddr is 0x42,
The regAddr is 0x00,
The cnt is 0x04
static bool hdc1010ReadFromRegister (uint8_t slvAddr, uint8_t regAddr, uint8_t cnt, uint8_t *rdBuffer)
{
int ret;
char data_write[3];
char data_read[6];
uint8_t slv_addr_8bit = (slvAddr << 1);
uint8_t i;
data_write[0] = (char)regAddr;
i2c.lock();
ret = i2c.write((int)slv_addr_8bit, data_write, 1, 1);
while(HDC1010_DRDYN_PIN.read());
if (ret == 0) {
ret = i2c.read((int)slv_addr_8bit, data_read, (int)cnt, 0);
if (ret != 0) {
i2c.unlock();
return false;
}
} else {
i2c.unlock();
return false;
}
i2c.unlock();
for (i = 0; i < cnt; i++) {
rdBuffer[i] = (uint8_t)data_read[i];
}
return true;
}
Regards,
Nelson
Hi Josh,
Using the above code, when I purposely touch the HDC1010_DRDYN_PIN pin to a ground pin, I can get the sensor's temperature and humidity readings.
It shows that the code is working. But when HDC1010_DRDYN_PIN pin is connected to the DRDYn pin of the sensor, it just doesn't go low.
Do you know why it is so? What have I missed that causes the pin doesn't go low?
Hope to hear from you soon.
Regards,
Nelson
Address lines? Bypass Cap?
Any logic captures of what your code behavior which you can compare to what i captured?
Nelson -
Can you check that you are respecting the tLOW time after start condition? (should be 1.3uSec or greater) - this would be measured from SCL at GND to base of first rise of next clock cycle - looks like you are at 20uSec per division, i looked at clock frequency based on that, looks like you are running 100kHz, so that is what led me to ask this question as it looks like it might be too short, what you have there. Also, this would shift everything over like its supposed to be - if you increase that time, as the ACKs here are questionable. They are not strong and they don't line up well with clock and i see an extra blip there in the middle, right after the ninth clock.
Did you also send the SOFT_RESET before this?
Can you try weaker pull up resistors?
Do you have the bypass capacitor installed?
Hi Josh,
Does it matter with 100kHz I2C? If it does matter, when I purposely touch the DRDYn pin to a ground pin, it won't be able to read the register 0x00 to 0x01 anymore. But when I touch the DRDYn pin to a ground pin, it can still read the registers. That means the 100khz I2C has no problem in reading.
The problem now is that why the DRDYn pin doesn't go low? Is that any possibility that you can think of?
Regards,
Nelson
Nelson -
i only brought up 100kHz because that is how I was justifying (via the timebase on the screen capture) that you were possibly not respecting I2C timing.
Please check it and the other items i mentioned.