Quantcast
Channel: Infineon Forums
Viewing all articles
Browse latest Browse all 9892

i2c help

$
0
0
Quote:

1. As I can see from the datasheet of INA3221 device, the slave address is 1000 00(A0)(R/W) (I hope it´s understandable). This A0 bit depends to which signal did you connect A0 pin. Can you verify that in your case this pin is connected to ground (this should set A0 bit to 0)?
Yes I do know that. The address I pass to the function is 0x80. I know that i2c only uses 7 bits for the address and that last bit is for R/W bit.
And I know the slave responds, because I get the ACK's.
Quote:

2. You could also include configuration of the output level for the both pins. It maybe be not necessary but you´re not doing anything wrong (as you can see the I2C protocol starts with both pins high). So just to the configuration structure add:
Code:

.output_level  = XMC_GPIO_OUTPUT_LEVEL_HIGH

done.

Quote:

3. You are requesting the read-out of the "Manufacturer ID" register as I can understand from your code. However, this register field is read-only so following code section is redundant:
Code:

XMC_I2C_CH_MasterTransmit(XMC_I2C0_CH1, 0xffU);
while((XMC_I2C_CH_GetStatusFlag(XMC_I2C0_CH1) & XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U)
{
/* wait for ACK */
}
XMC_I2C_CH_ClearStatusFlag(XMC_I2C0_CH1, XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED);


Whoops.. it's actually the wrong address too.. .it's 0xFE that I want. So I just removed this.

Quote:

Also you can see that in the documentation where is stated:
Code:

To change the register pointer for a read operation, write a new value to the register pointer.
This write is accomplished by issuing a slave address byte with the R/W bit low, followed by the register pointer byte.
No additional data are required.


Yup. Understood.

Quote:

4. This first "XMC_I2C_CH_MasterStop()" function call (right before "XMC_I2C_CH_MasterReceiveNack" function call) should not be there. You only transmit STOP bit at the end of transmission, as you done properly in your code at the end before "while" loop. So you should remove this function call.
Yeah that was stupid.
I just took out the while loop and now I just ask for two bytes which should give me 0x5449 according to the datasheet.
Quote:

Try to modify the code based on my suggestions and let me know do you still have issue.
Also, please let me know does your code successfully reaches "while" loop (meaning all the ACK bits are received and accepted). It would be nice if the issue is still present to screenshot the PSR_I2Cmode register just before and after you should receive data.
I have attached the latest code with your modifications. I've also attached a screenshot from my scope. You can see that the slave is answering me and I think I'm doing everything right.
That's why I'm perplexed.


Thanks for your help, I really appreciate it.
Attached Files

Viewing all articles
Browse latest Browse all 9892

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>