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.

16 bit data write using I2C interface in OMAPL138

Other Parts Discussed in Thread: INA219, LM75A, OMAP-L138

Hi

I am facing  some problems; while trying to write a 16bit config register data to INA219 V&I Monitor using I2c. so i need some clarification on whether 16bit write is possible (Reg. Pointer + databyte 1  + databyte 2) . If this pattern is wrong , try to help me by providing the steps to do so. i didn't find any difficulty in 16bit read from INA219 registers.

Along with that i need clarification on whether there is a need of sending the (slave address + R/W) data apart from writing data to the SAR Reg and Tx/Rx bit in ICMDR Register.

Hoping for some helping hands from someone

Thanks

 

 

----------------------------

uint32 uint32_INA219RegisterWrite ( uint16 in_addr,  uint8 in_reg_addr, uint8 in_databyte1, uint8 in_databyte2)

{

   uint32 rtn;

   uint8 uint8_I2Cdata[3];

 

   //array for storing register pointer & 2xbyte of data

   uint8_I2Cdata[0] = in_reg_addr;

   uint8_I2Cdata[1] = in_databyte1;

   uint8_I2Cdata[2] = in_databyte2;

 

    // write the register 

rtn = uint32_I2CWrite(I2C0, in_addr, uint8_I2Cdata, WRITE_LENGTH, SET_STOP_BIT_AFTER_WRITE);

return (rtn);

}

 

 

uint32 uint32_INA219RegisterRead(uint16 in_addr, uint8 in_reg_addr, uint8 *dest_buffer)

{

uint32 rtn;

 

   // write the register address that we want to read.

   rtn = uint32_I2CWrite(I2C0, in_addr, &in_reg_addr, ADDRESS_LENGTH, SKIP_STOP_BIT_AFTER_WRITE);

   if (rtn != ERR_NO_ERROR)

   return (rtn);

 

   // clock out the ina219 register data.

   rtn = uint32_I2CRead(I2C0, in_addr , dest_buffer, READ_LENGTH , SKIP_BUSY_BIT_CHECK);

 

   return (rtn);

}

  • The datasheet for INA219 indicates that it does use a repeated start for read operations. I am not familiar with your I2C libary. I am guessing the code should look something like this:

    uint32 uint32_INA219RegisterWrite ( uint16 in_addr,  uint8 in_reg_addr, uint16 in_data)
    {
      uint32 rtn;
      uint8  uint8_I2Cdata[3];

      //array for storing register pointer & 2xbyte of data
      uint8_I2Cdata[0] = in_reg_addr;
      uint8_I2Cdata[1] = (uint8)(in_data >> 8); // MSB
      uint8_I2Cdata[2] = (uint8)in_data;        // LSB

      // write the register
      rtn = uint32_I2CWrite(I2C0, in_addr, uint8_I2Cdata, 3, SET_STOP_BIT_AFTER_WRITE);
      return (rtn);
    }

    uint32 uint32_INA219RegisterRead(uint16 in_addr, uint8 in_reg_addr, uint16 *out_data)
    {
      uint32 rtn;
      uint8  uint8_I2Cdata[2];
      uint16 temp;

      // write the register address that we want to read.
      rtn = uint32_I2CWrite(I2C0, in_addr, &in_reg_addr, 1, SET_STOP_BIT_AFTER_WRITE);
      if (rtn != ERR_NO_ERROR) return (rtn);

      // clock out the ina219 register data.
      rtn = uint32_I2CRead(I2C0, in_addr , uint8_I2Cdata, 2 , SET_STOP_BIT_AFTER_READ);
      if (rtn != ERR_NO_ERROR) return (rtn);

      temp   = uint8_I2Cdata[0]; // MSB
      temp <<= 8;                // Shift into upper spot.
      temp  |= uint8_I2Cdata[1]; // LSB

     *out_data = temp;

      return (rtn);
    }

  • thank u for the response 

  • Hi 

    i just want someone's view on the  issue with I2C. i am working with 9 I2C slaves (6 INA219, 2 LM75A and PMIC) . in testing all the 6 INA219 IC's works perfectly but the 2x LM75 IC,s are not responding it will pull the busy bit to HIGH . i used the same code for INA219 read/write; the only difference is the I2C address . we also used a I2C level shifter in the Bus (1.8V -> 3.3V) for the INA219 but the logic level have no conflicts with LM75. Is ther any suggessions other than the issues like bus levels , logic levels slave address error .

  • Is OMAP-L138 operating at 1.8V or 3.3V?

    What are the voltage levels for OMAP-L138, INA219 and LM75?

    Sorry, I don't have noticed anything else

    Regards,

    GSR

  • Hello ESR,

                        The CPU of the OMAP L138 1.2 V / 1.3 V but GPIO is configurable for 1.8V or 3.3 V. But I2C bus of OMAP L138is 1.8 V signal only. Voltage level of INA219 : 3.0 to 5.5V & LM75 Operating voltage level is approx 2.7 V to 5.5 Volt. Level Shifter is recommended for both device. Please confirm LM75 or LM75A.

    -- Abhijit

  • Hi all

    OMAP L138 is working at 1.8V

    INA219 - 3.3V

    LM75AIM - 3.3V

    for more information , NACK bit in the ICSTR Reg is TRUE after the ICMDR Reg Configuration. I analyse it as a missing of ACK after sending address so is it advisable to look on clock skew or any other delay problems specifically with hardware ?

  • Some usual questions. What is the SCL frequency? The LM is a slower device than the INA. What is the value of the pullup resistors on SCL and SDA? The OMAP-L138 might have internal pullups.

  • thanks for your replies .

    We diagnose  it as a problem with delay and track  .  With the help of I2C analyzer we found out  the cause. So we worked with hardware and now the LM75 AIM IC is acknowledging correctly .

    I prefer I2C analyzer as best way to find out issues with I2C communication 


     

  • Abhijit,

    I was not able to find any information in the OMAP L138 datasheet about the I2C voltage being only 1.8V capable.  It looks like it is in the DVDD3318_A power group which is configured for 3.3V in our application.

    Thanks for clarifying,

    Scott Battocchi