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.

INA219: Can't write in the registers

Part Number: INA219

Hello everybody,

I am always working on my INA219's board, I know how to calculate correctly calibration reg now, but I can't write it in the memory.

I am using two boards, a custom one with some components on it, including two INA219 (with differents I2C @) and a Raspberry Pi 4 connected through the SDA and SCL. I can detect the two IC on the Bus, I can also dump the registers but I can't write in it. 

First it appears me weird that the registers are recurring, on the screenshot below you can see "39 7d 1b 00 00 00 20 82" twice on each line,is that normal ? 

After that, I saw in the D/S that the registers are 16 bits longs so can you tell me if my understanding is right in my table please ?

Register name @ of the first part @ of the second part
Configuration 0x00 0x01
Shunt voltage 0x02 0x03
Bus voltage 0x04 0x05
Power 0x06 0x07
Current 0x08 0x09
Calibration 0x0A 0x0B

So I calculate a calib register : 0x8312 and I write on my raspberry :

i2cset -y 1 0x40 0x0A 0x83 0x12 i

But the only change is the 0x0a register, it came from 0x1b and the value is now 0x1c can you help me please ?

Best regards 

Lucas 

  • Hello Lucas,

    Do you have a scope shot?  Does it look like the diagram in the datasheet?

  • Hello Javier, thanks for your answer.

    Yes I can, but I have an old oscilloscope so I had to take pictures of its screen.

    I took 4 pictures, you can see my cursors showing 9 bits groups and my command is :

    i2cset -y 0x40 0x05 0x83 0x12 i

    - Start + 9 firsts bits : (0x40)

    - 9 second bits : (0x05)

    - 9 thirds bits : (0x83)

    - 9 fourths bits : (0x12)

    The frames seems to be good for me.

    Best regards

    Lucas

  • Hello Lucas,

    On the second command I do not see the acknowledge.  I am not sure if that is correct.  Also when you read back are you changing your register pointer for each read?

  • Hi Javier,

    I solve my problem, the writing was good, the problem was the displaying of the datas. If think the INA219 send one adress and 2 bytes after it, so my terminal didn't show the second one each time.

    It works with the command :

    i2cdump -y 1 0x41 w

    You can see at @0 0x9f39 (the reset value) and at @5 0x1283, my calib value. The two bytes are reversed but it's good for me. Thanks for the help, I will continue my hardware's work and I'll take time after it to develop a program working with the INA.

    Best regards

    Lucas