Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello,

i'm using a USIC channel from XMC4500 as a I2C master to communicate with a I2C slave, placed in an FPGA.
The code i use for the I2C master is based on the DAVE-App I2C001/0 (version 1.0.28).

Now there is a random and quite frequent communication error in the case of an I2C repeat start condition.
After sending the slave adress, a 2. and a 3. byte (command and operand, see code below), the master doesn't send the restart condition byte in the error case.
The function 'I2C001_WriteData' returns succesfully, but the byte is not given out on the I2C data line! So the FPGA hangs afterwards, because it's waiting for the restart condition. In normal operation the repeat restart condition is send to trigger a readout of 3 bytes from slave. So the master switches from transmitter to receiver and the slave vice versa at that time.

Does anybody had a similar problem with the I2C as a master.
Thanks in advance.

Christian


//start + adress
laddr = addr << 1;
data.Data1.TDF_Type = I2C_TDF_MStart;
data.Data1.Data = (laddr | I2C_WRITE);
while(!I2C001_WriteData(&I2C001_Handle0,&data));

//cmd
data.Data1.TDF_Type = I2C_TDF_MTxData;
data.Data1.Data = cmd;
while(!I2C001_WriteData(&I2C001_Handle0,&data));

//operand
data.Data1.TDF_Type = I2C_TDF_MTxData;
data.Data1.Data = op;
while(!I2C001_WriteData(&I2C001_Handle0,&data));

//repeat start + adress
data.Data1.TDF_Type = I2C_TDF_MRStart;
data.Data1.Data = laddr | I2C_READ;
while(!I2C001_WriteData(&I2C001_Handle0,&data)); <= data isn't send out, but returns true
0 Likes
1 Reply
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi,

You can find many I2C example from here. Just type I2C in the search filter box.

http://www.infineon.com/cms/en/product/promopages/aim-mc/dave_downloads.html
0 Likes