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.

MSP430G2553 I2C Hold Master SI7020

Hello, i Am Trying comunicate with SI7020 Temp/Humidity sensor via I2C. How I wait in Hold Master mode? Or No Hold Master... Now is data is "0" and SCL still always low... Complete code is in the RAR. Thank You!

LED_HUMIDITY.rar

  • You're not enabling interrupts (GIE) so I suspect you're stuck in the I2C_Write, with the I2C unit waiting for you to give it the RH_HOLD command (TXIFG). You should probably add an __enable_interrupt() in main.

    You probably want to stick with Hold Master mode, since you don't seem to provide a way of reporting a NACK. SLAU144J sec 17.3.5.1 claims the I2C can deal with clock stretching just fine.
  • Now is full work! Thank You. I put one line in the I2C read rutine- while(UCB0STAT &= ~UCSCLLOW); Please check me code is it without bug. Thank You.

    void I2C_Read(unsigned char byteCount, unsigned char *field)
    {
    while(UCB0STAT &= ~UCSCLLOW); //Only Hold Master-for SI7020
    TI_receive_field = field;
    if (byteCount == 1)
    {
    byteCtr = 0;
    __disable_interrupt();
    UCB0CTL1 |= UCTXSTT; // I2C start condition
    while (UCB0CTL1 & UCTXSTT); // Start condition sent?
    UCB0CTL1 |= UCTXSTP; // I2C stop condition
    __enable_interrupt();
    }
    else if (byteCount > 1)
    {
    byteCtr = (byteCount - 2);
    UCB0CTL1 |= UCTXSTT; // I2C start condition
    }
    else
    while (1); // illegal parameter
    }

**Attention** This is a public forum