read data by sense registers
For LTC4151, I am supposed to read the current (ampere) value that is in sense registers (0x00 and 0x01)
the steps I have followed to implement this in vhdl is
S1: start->slave address->write->slave ack ->control register address (0x06h)-> slave ack-> data to be written (10111000)->slave ack->stop
S2: start ->slave address->write->slave ack ->control register address (0x06h)-> slave ack-> restart->slave address-> read->control register data read -> master nack -> stop
S3: start ->slave address->write->slave ack ->sense A register address (0x00h)-> slave ack-> restart->slave address-> read->slave ack-> data read (8 MSB) -> master nack -> stop
S4: start ->slave address->write->slave ack ->sense B register address (0x01h)-> slave ack-> restart->slave address-> read->slave ack-> data read (4 LSB) -> master nack -> stop
but i am just held up in step 3
S1 ,S2
S3 :start ->slave address->write->slave ack ->sense A register address (0x00h)-> slave ack-> restart->slave address-> read-> slave ack-> data read (8 MSB) -------
the data read is continuous and it is not terminating even after giving stop condition, Because of this I am not able to proceed for step S4.
Please help me on resolving the issue.
Thank you
amplifiers
Specialty Amplifiers
LTC4151
Current Sense Amplifiers
Greetings LR237,
Can you provide a scope shot of the I2C transaction? Its hard to say what's going on exactly without being able to see more details. There are a few things you can try:
1. Try to read the sense register using the read word protocol (this is the preferred method).
2. What you are describing sounds like a paged read:
When using the Read Page and Write Page commands, the host need only to issue an initial register address and the internal register address pointer automatically increments by 1 after each byte of data is read or written. After the register address reaches 06h, it will be reset to 00h and continue the increment. Upon a Stop condition, the register address is reset to 00h.
For reads:
The LTC4151 acknowledges and sends the contents of the requested register. The transmission terminates when the master sends a Stop condition. If the master acknowledges the transmitted data byte, as in a Read Word command, the LTC4151 will send the contents of the next register. If the master acknowledges the second data byte and each of the following (if more) data bytes, as in a Read Page command, the LTC4151 will keep sending out each data byte in the register that corresponds to the incrementing register pointer. The read operation terminates and the register address pointer resets to 00h when the master sends a Stop condition.
Try disabling the Read/Write Page commands by clearing control register bit G3.
3. You can look at some tried and tested example code for the LTC4151 by looking at the Linduino sketch and libraries listed on the product page (https://www.analog.com/en/products/ltc4151.html#product-documentation) or in the LTSketchbook.
Best regards,
Brad
Hi LR237,
I also noticed, based on the data written in S1 (10111000 or 0xB8 ), you are setting the part into snapshot mode for Vin, enabling test mode, enabling page r/w, and disabling the stuck bus timer. Is this the intended behavior?
Brad
Sorry for type error. Actually , the data written in S1 (10011100 or 0x9C) for sense registers. i want to read 1 byte data for sense A register (0x00) and another 1 byte data for sense B register (0x01). I need to know what settings has to be made and written into control register (0x06) so that it enables only the sense registers to put out the data and I2C master should be able to read it irrespective of the register address provided?
Sorry for type error. Actually , the data written in S1 for control register (10011100 or 0x9C) for sense registers. I want to read 1 byte data for sense A register (0x00) and another 1 byte data for sense B register (0x01). I need to know what settings has to be made and written into control register (0x06) so that it enables only the sense registers to put out the data and I2C master should be able to read it irrespective of the register address provided?
the sense A register (0x00) seems to be continuously read some data values and it is not terminating even when stop condition is given. because of this I am not able to read sense B register (0x01) value also.
I think it is related to how the setting is done in the control register.
Could you please help me in resolving the issue?
Thank you
Hi LR237,
I would recommend setting up register 0x06 as such:
This will disable the page reads and test mode, set up a single ADC snapshot for the sense register, and keep the stuck-bus timer enabled. Then, do a read word of the sense register. I you are able to get sensible data back from the read (per our previous conversation), you can then switch to continuous mode, if needed, and see how it goes. Let me know how it goes and if you have any other questions!
Thank you and best regards,
Brad
Hi,
I have some queries.
1. is it really necessary that control register (0x06) has to be configured first by writing the data (10000100) into it and then perform read operation for registers (0x00 and 0x01)?
2. can i directly read the data from registers (0x00 and 0x01) without configuring the control register?
3. are the below steps which iam following is correct or not?
S1: Start > slave address > write(0) > slave ack >control register address (0x06) > slave ack >data written (10000100) > slave ack > stop
S2: Start > slave address >write (0) > slave ack > reg1 (0x00) > slave ack > restart > slave address > read (1) > slave ack > data read > stop
S3: Start > slave address >write (0) > slave ack > reg2 (0x01) > slave ack > restart > slave address > read (1) > slave ack > data read > stop
4. can i just follow the below mentioned step to read data? will it work without configuring the control register (0x06)?
Start > slave address >read (1) > slave ack > reg1 (0x00) > slave ack > data read > stop
Start > slave address >read (1) > slave ack > reg2 (0x01) > slave ack > data read > stop
Greetings LR237,
LR237 said:
1. is it really necessary that control register (0x06) has to be configured first by writing the data (10000100) into it and then perform read operation for registers (0x00 and 0x01)?
It is not absolutely necessary to have the exact value of 0x84 written into the control register. I was recommending this value to get you off to a good start with a snapshot reading. You can set the control register to any value, as long as you understand what each bit does.
LR237 said:
2. can i directly read the data from registers (0x00 and 0x01) without configuring the control register?
Yes. But it is generally a good idea to know what is in the control register before trying to read data.
LR237 said:
3. are the below steps which iam following is correct or not?
S1: Start > slave address > write(0) > slave ack >control register address (0x06) > slave ack >data written (10000100) > slave ack > stop
Yes, this looks like you are writing 0x84 into 0x06. If that is the what you are trying to do, I don't see any issues. Is the LTC4151 acking when expected?
LR237 said:
S2: Start > slave address >write (0) > slave ack > reg1 (0x00) > slave ack > restart > slave address > read (1) > slave ack > data read > stop
LR237 said:
S3: Start > slave address >write (0) > slave ack > reg2 (0x01) > slave ack > restart > slave address > read (1) > slave ack > data read > stop
These appear to be read bytes of the sense registers, but you are missing the NACK from the master between the data read and the stop. This bit tells the slave to stop sending bytes. As mentioned in an earlier response, if the master acks the read data then the LTC4151 will increment it's register pointer and send the next byte of data.
In fact, the extra ack and read data is the only difference between the read byte and read word protocols here:
LR237 said:
4. can i just follow the below mentioned step to read data? will it work without configuring the control register (0x06)?
Start > slave address >read (1) > slave ack > reg1 (0x00) > slave ack > data read > stop
Start > slave address >read (1) > slave ack > reg2 (0x01) > slave ack > data read > stop
This is not allowed. Please see page 9 of the datasheet for the correct protocols. You must write the register to be read to the LTC4151 after the LTC4151 acks its address and before attempting to read it's data. As previously mentioned, the best way to read the SENSE register would be to perform a read word command.
Start > slave address > write(0) >slave ack > repeated Start > slave address > read(1) >slave ack >
1st byte of read data > master ack > 2nd byte of read data > master nack > stop
I hope this helped! Let me know if you have any other questions!
Best regards,
Brad
Please log in to reply.



