XMC4500 Using USIC2_CH1 as I2C

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

cross mob
Not applicable
/*
Hello, I am using USIC2_CH1 as I2C. I am having problem to send out the stop bit in the data frame. By debugging I alway got the information that Tx FIFO is full.

Here are more details. I am using XMC4500 Hexagon Application Kit ( CPU_45A_V3, using ACT extension UNI_EXT01-V02). I am using Dave3. I have first tested the code using other usic channel; and the code worked fine.

Now I have to use another usic channel, which we will eventually use for our prototype board. But now I am being stopped where, I am writing the stop bit of the I2C frame. Here is the code:

*/

void I2C_Write(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len) {

I2C001_DataType data1,data2,data3,data4;
int16_t i;


while (RDY() == 1); // wait for RDY pin to go low

data1.Data1.TDF_Type = I2C_TDF_MStart;
data1.Data1.Data = (addr | I2C_WRITE); // address
while(!I2C001_WriteData(&TOUCH_I2C_HANDLE,&data1));

// Set register
data2.Data1.TDF_Type = I2C_TDF_MTxData;
data2.Data1.Data = reg; // register
while(!I2C001_WriteData(&TOUCH_I2C_HANDLE,&data2));


data3.Data1.TDF_Type = I2C_TDF_MTxData;
for (i=0;i data3.Data1.Data = data;
while(!I2C001_WriteData(&TOUCH_I2C_HANDLE,&data3));
}


// Stop condition by the master
data4.Data1.TDF_Type = I2C_TDF_MStop;
data4.Data1.Data = ubyteFF;
/* I am kept within this while loop and cannot get out of here, any help ....*/
while(!I2C001_WriteData(&TOUCH_I2C_HANDLE,&data4));



delay_ms(1);

taskENTER_CRITICAL();
while (RDY() == 0);
while (RDY() == 1);
taskEXIT_CRITICAL();

}


/*
can anybody help out of the while loop, where I am writing the stop bit of the I2C frame?

*/
0 Likes
6 Replies
Not applicable
Hi Shenj,

May I know which pin are you using for the project which doesn't work?
0 Likes
Not applicable
Jackson wrote:
Hi Shenj,

May I know which pin are you using for the project which doesn't work?


Hi Jackson,

exactly P4.2 (SCL) and P4.7 (SDA), which you have discussed previously with andersr. Debug shows that FIFO is full; Workarounds with TBUF[0] etc were also unsuccessful. andersr has changed the I2C to other port (?). Which Pins did he/she use?

Big question is if P4.2 and P3.4 can work together as I2C with xmc4500 AB and AC version. I am having AB development board, our product will however use xmc4500 AC. In addition, I am not having so much freedom in changing to other pins.

Many thanks in advance.
0 Likes
Not applicable
Hi shenj,

Perhaps you have missed the post for andersr where he mentioned he changed the SDA pin to P3.5.
The reason for P4.7 is not working because P4.7 does not have both both DOUT and DX0 functionality..
In order to use as SDA pin, the pin itself must have both DOUT for the outputs and DX0 for the input.

P3.4 is not suitable to be use as SDA pin as it does not support DOUT functionality.
I would recommended you to use P4,2 as SCL and P3.5 as SDA just like what andersr had use.

The pins that works on AB device for USIC function will be works on AC device too.
0 Likes
Not applicable
Hello Jackson.

I wish to know if P4.2 and P4.7 works for XMC4500 Step-AC. This is a question from our hardware engineer, who designs our electronic.

Second question is that it seems P4.7 can be configured as both DX0 and DOUT0 ( see XMC4500 Reference Manual Table 17-30. Pages 1812 and 1814). Please comment if in general HW port control works not.

Thanks again.
0 Likes
Not applicable
Hi shenj,

For P4.7, it is a HW controlled IO pin for USIC function but is only mean for multi-IO SPI mode.
For HW controlled IO, the output driver is fixed to push-pull only (to support the multi-IO SPI mode) but I2C needs open drain driver mode.
Therefore, I don’t think the pin P4.7 will work.
0 Likes
Not applicable
Thanks. Issue closed.
0 Likes