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.

INA228: Failed to communicate with INA228

Part Number: INA228

Tool/software:

ello everyone,

 I'm interfacing an INA228  with an STM32 microcontroller  via the I2C bus. However, I'm facing a problem with the communication that I can't seem to resolve.

Setup Details:

  • Microcontroller: STM32h7 (using HAL library)
  • INA228 connected via I2C
  • API Used: HAL_I2C_Transmit (blocking mode)
  • I2C Clock Speed: Tested at both 100 kHz and 400 kHz
  • Pull-up Resistors: 2.2 kΩ on SDA and SCL lines
  • Configuration of GPIO in STM32h7: 
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;

Issue:

I'm trying to write a pointer register on the INA228 by sending a 1-byte data, in order to perform then a read on this register:

  1. The register address (1 byte)

I'm calling HAL_I2C_Master_Transmit(&hi2c1, INA228_ADDRESS<<1, txBuf, 1,HAL_MAX_DELAY)

txBuf contains address of register.

In most cases, the INA228 responds with a NACK. However, i tried putting my HAL_I2C_Master_Transmit in a loop and at a  random iteration, device responds correctly and the transmission is successful.  when its successful i tried reading register content using HAL_I2C_Master_Receive but it fails with error HAL_I2C_ERROR_AF (NACK)

 
Steps I've Taken:
  1. Verified the I2C address of the INA228 using HAL_I2C_IsDeviceReady --> no detection of INA228, i saw in a post that HAL_I2C_IsDeviceReady had a bug (i'm using V1.11.0), so i stopped relying on it.
  2. Checked the waveform with a logic analyzer; the data being sent appears to be correct.
  3. Reduced the I2C clock speed to 100 kHz — no improvement observed.
  4. Tried adding small delays between the register address byte and the data bytes — issue persists.

Has anyone experienced similar issues with the INA228 using the STM32 HAL library?

  1. Could this be related to timing or specific delays required by the INA228 that are not documented?
  2. Are there any additional I2C settings or configurations in the STM32 HAL that might help with this issue?

Any help or suggestions would be greatly appreciated! Thanks in advance

  • Please show an oscilloscope trace of the failing write.

  • I notice a desynchronization between the data and the clock, is that correct?

    Link to STM32 forum: community.st.com/.../744295

  • Hello,

    It looks like the data logic level low is not going low enough. The INA228 needs to have a logic level low no higher than 0.4V. Often this is caused by the MCU's ability to sink current into the pin. So, you have two options:

    1. Many MCU's have a setting to change the current sink capability, if you increase the current sink capability then it will be able to pull the low line closer to GND.

    2. You can use a larger pullup resistor. Since you are communicating at only 100KHz and 400KHz, you would be fine with a 10kΩ resistor instead of a 2.2kΩ.

    Regards,

    Mitch

  • Hello Mitch, thanks for your reply, i missed some important details that i explained in this post: https://community.st.com/t5/stm32-mcus-products/i2c-communication-with-ina228-from-texas-instrument/m-p/744241 (My mcu is connected to INA228 via an isolater ADUM1250)

    I'll consider your observation about the low level.

    It's not a problem that first bit low of data is not synchro with clock ? I found this a bit strange ..

  • SDA is sampled only on the rising edge of SCL. The falling edge on SDA while SCL is high is the start condition. The timing of these waveforms is OK.

  • Hello,

    As Clemens noted, the timing is fine.

    Since you are using an isolator, you'll want to check the logic high and low levels on both sides of the isolator. Many isolators have different specs for each side of the isolator, so sometimes switching the isolator around can help. I've also seen that adding a small capacitor to GND on the communication lines on both side of the isolator can also help (~33pF).

    As a side note, you may be interested in our isolated ADCs. We have some that are focused on current sensing and can operate from either a single or dual supply:

    https://www.ti.com/isolation/isolated-adcs/overview.html

    Regards,

    Mitch