I2C001_WriteData hangs up

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

cross mob
Not applicable
Hi!
I've written a piece of code to read data on the IIC-Bus (similar to the example of the help) using the APP I2C001[1.0.12]

IIC_Data1.Data1.TDF_Type = I2C_TDF_MStart;
IIC_Data1.Data1.Data = 0x80;
I2C001_WriteData(&I2C001_Handle0, &IIC_Data1);

IIC_Data2.Data1.TDF_Type = I2C_TDF_MTxData;
IIC_Data2.Data1.Data = 0x02;
I2C001_WriteData(&I2C001_Handle0, &IIC_Data2);

IIC_Data3.Data1.TDF_Type = I2C_TDF_MRStart;
IIC_Data3.Data1.Data = 0x81;
I2C001_WriteData(&I2C001_Handle0, &IIC_Data3);
....

The Problem ist that in the 3rd call of I2C001_WriteData-Funktion the program hangs up and the debugger crashs. The free running program is not working.
The transmit FIFO size is >2. (e.g. 16)

Any ideas?
Carsten
0 Likes
10 Replies
ron
Employee
Employee
Hey Carsten,

do you using a Board from IFX, if yes, can you post the complete project so that we can reproduce the problem.
0 Likes
Not applicable
Hi Ron,
I'm using the XMC4500 Relax Kit.
Last year in september I build up a project with an old I²C App running on the hexagon-kit without any problem.

Which files do you need? The whole project folder is too big to upload.
0 Likes
ron
Employee
Employee
Hey

then please send me the Main.c file. This should be ok and the Pins you are using for the IIC Pins.
0 Likes
lock attach
Attachments are accessible only for community members.
Not applicable
Hi Ron,
I'm using P5.2 as SCL and P5.0 as SDA line.
Beside the I²C-App, I'm using the USBVC001 App.
0 Likes
ron
Employee
Employee
Hey Carsten,

I try to reproduce your issue but I can not find a problem. I'm using a Hexagon Kit with the IO expander, for debugging I use the segger debugger. Can you try to find out where exactly on you side the program stops working, go step by step trough the code. Then try to create a standalone project just with IIC and use onyl one sequence to read the temp for example.

I modify you code a bit to have a kind of error handling.

do{
IIC_Data1.Data1.TDF_Type = I2C_TDF_MStart;
IIC_Data1.Data1.Data = 0x9A; //IO expander
IIC_Status = I2C001_WriteData(&I2C001_Handle0, &IIC_Data1);
if (IIC_Status==FALSE)break;

IIC_Data2.Data1.TDF_Type = I2C_TDF_MTxData;
IIC_Data2.Data1.Data = 0x08; //Register 0x08
IIC_Status = I2C001_WriteData(&I2C001_Handle0, &IIC_Data2);
if (IIC_Status==FALSE)break;

IIC_Data3.Data1.TDF_Type = I2C_TDF_MRStart;
IIC_Data3.Data1.Data = 0x9A |0x01; //Address + 1 for read
IIC_Status = I2C001_WriteData(&I2C001_Handle0, &IIC_Data3);
if (IIC_Status==FALSE)break;

IIC_Data4.Data1.TDF_Type = I2C_TDF_MRxAck1;
IIC_Data4.Data1.Data = 0xFF;
IIC_Status = I2C001_WriteData(&I2C001_Handle0, &IIC_Data4);
if (IIC_Status==FALSE)break;

}while(0);

IIC_Data5.Data1.TDF_Type = I2C_TDF_MStop;
IIC_Data5.Data1.Data = 0xFF;
IIC_Status = I2C001_WriteData(&I2C001_Handle0, &IIC_Data5);


if (IIC_Status==FALSE){
USBVC001_SendString((const char *)" Transfer FAIL");
/* here the I2C Bus error handling must be added*/
}
else{
IIC_Status = I2C001_ReadData(&I2C001_Handle0, &ReceivedData);
ReceivedData = (ReceivedData & 0xFF);
USBVC001_SendByte(ReceivedData);

}
0 Likes
Not applicable
Hi Ron,
I've created a new project only using the I2C-App. But I still have the problem with the 3rd call of the I2C001_WriteData call.
In single step the program stops working at
if(I2CRegs->PSR_IICMode & USIC_CH_PSR_IICMode_WTDF_Msk)
0 Likes
Not applicable
Hi Ron,
I had a closer look to the hardware and put a oscilloscope on SCL and SDA lines. There are no changes. The lines are all on 3.3V because of the 10k pullups I've connected.

As said. In the past I had no problem on the Hexagon Kit. So this could be an issue with the relax kit.
0 Likes
Not applicable
Hi Ron,
I changed the I2C Pins to 0.8 + 1.5. Now it's working. Even if there is no i2c slave the function doesn't crash.
So i think you have a problem with the setting to 5.0 + 5.2 as i2c pins.
0 Likes
ron
Employee
Employee
Hey Carsten,

just for post all the informations we exchange outside of the forum.
On XMC4500 AA13 Step which is currently on all of our Kit's we have an issue with the USIC2 FIFO which is used in the I2C001. --> USIC_AI.012 USIC2 does not provide FIFO buffer
capability
Therfore on the latest DAVE3 version and App's I can not assign the 5.0 + 5.2 as i2c pins.
Never the less I can not reproduce the program hangs up and the debugger crashs. The reason is if there is no Slave connected on the pins the USIC will stop stranfering data after the first word he send out when not getting a ACK from the Slave IC.
0 Likes
Not applicable
Hello,

I am currently trying to implement a I2C master but the error handling of NAK is the problem. According to the manual data transmission is stopped. But I would like to use the FIFO. But how do I the error handling? The best thing was if I could write to the FIFO and then check with a flag whether it succeed or not.

Kind regards,
Christian
0 Likes