Skip to main content
Visitor II
March 28, 2019
Question

HTS221 blocks SDA line

  • March 28, 2019
  • 4 replies
  • 1064 views

I tried to connect the HTS221 to the ATtiny816 via the I2C bus. The data availability survey was conducted 2 times per second:

if ((HTS221_GetCTRL_REG2() == 0) && ((HTS221_GetStatus() & 0x03) == 0x03)) {

         HTS221_GetData(&HTS221_Rx_buf);

...

}

Oscillograms of STL and SDA lines were correct, regardless of the amount of received data (1..4 bytes).

Converting the resulting data resulted in correct humidity and temperature results.

However, with constant interrogation of the sensor, SDA line was blocked in the lower state in a random time. And further work was resumed only with the re-power on the Vdd.

This lock occurred both in case of auto-increment reading of results registers, and one at a time. This block occurred both during the automatic start of the conversion (tried 1 and 7 Hz) and “one-shot�?.

The blocking of SDA lines was resolved only in the case of reading only one register, for example HUMIDITY_OUT_H. This allows to obtain humidity with an accuracy of 1%.

void HTS221_GetData(HTS221_data_t* Buf)

{

   SubAddress = 0x28 | 0x80; // from HUMIDITY_OUT_L

   I2C_SUB_IN(&Buf->bytes.H_OUT_byte0, HTS221RdAddr, 2); // 2 bytes

}

<----- Does not work long !!!

void HTS221_GetData(HTS221_data_t* Buf)

{

   SubAddress = 0x29; // from HUMIDITY_OUT_H

   I2C_SUB_IN(&Buf->bytes.H_OUT_byte1, HTS221RdAddr, 1); // ONLY 1 BYTE

}

<------ It works long enough !!!

    This topic has been closed for replies.

    4 replies

    ST Employee
    April 2, 2019

    Hi Lehman, could you share the oscilloscope pattern?

    Btw, which drivers are you using? Please consider this thread if it could be useful for you https://community.st.com/s/question/0D50X0000AU57uOSQR/hts221-sensor-driver

    regards

    LehmanAuthor
    Visitor II
    April 5, 2019

    Hi, Eleon.

    Ok. Easy!

    For example - reading CTRL_REG2 (SubAddress = 0x21) - image 1.

    Image 2 - 500nS/dev expansion of point near +60uS on image 1.

    Driver i2c - handmade. I have not found for ATTiny.

    However, the ATH10 (China) sensor is located on the same i2c bus - it does not hang.

    Pull-up resistors (SDA, SCL) - 5k6.

    CubeMX driver only for ST microcontrollers. May be it will work correct.

    0690X0000089ytVQAQ.jpg0690X0000089yu4QAA.jpg

    LehmanAuthor
    Visitor II
    April 5, 2019

    Hi, Eleon.

    I can not catch the moment of the SDA line stop in 0, because it happens at a random time.

    Best regards.

    ST Employee
    April 5, 2019

    Hi Lehman, so you are building your I2C pattern in bit-banging, right? I'm checking your I2C patter for the multi-byte read case

    0690X0000089zmGQAQ.png

    First data byte is correctly read, while the second one is't. Are you correctly managing the MAK?

    Which is the slave addr of the other sensor sharing I2C line, the ATH10?

    Btw, did you tried with one of these already written drivers?

    I'll check if we can suggest you Atmel divers implemented by us.

    Regards